Saturday, July 4, 2009

Get Incident Details via Javascript

Hi,
here is an example to get incident details from server only from javascript side

function GetIncidentDetails(IncidentId) {
var xml = "" +
"" +
GenerateAuthenticationHeader() +
" " +
" " +
" " +
" " + "incident" + "" +
" " +
"
" +
" false" +
" " +
" And" +
" " + "incidentidEqual" + incidentId + "" +
"
" +
"
" +
"
" +
"
" +
"
" +
"";
var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xmlHttpRequest.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple");
xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
xmlHttpRequest.send(xml);
var resultXml = xmlHttpRequest.responseXML;
var entityNode = resultXml.selectSingleNode("//RetrieveMultipleResult/BusinessEntities");
return entityNode;
}

Enjoy,
Rami Heleg.