Monday, February 6, 2012

MS CRM 2011: how to assign a case to queue in Javascript using SOAP Endpoint?

Use the following line of code to move a case or incident from one assigned queue to another queue

It's a fully tested code just copy and paste after change the record. source and destination Guid

//Move case from 1 queue to another queue
var recordid="8B1A6B37-5451-E111-B17D-00155D00A500";
var sourceQueueid="d9192f47-b650-e111-b17d-00155d00a500";
var destinationQueueid="da192f47-b650-e111-b17d-00155d00a500";

var header = Xrm.Page.context.getAuthenticationHeader();

var xml = "" +
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
header +
" <soap:Body>" +
" <Execute xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" +
" <Request xsi:type=\"RouteRequest\">" +
" <Target xsi:type=\"TargetQueuedIncident\">" +
" <EntityId>" + recordid + "</EntityId>" +
" </Target>" +
" <SourceQueueId>" + sourceQueueid + "</SourceQueueId>" +
" <RouteType>Queue</RouteType>" +
" <EndpointId>" + destinationQueueid + "</EndpointId>" +
" </Request>" +
" </Execute>" +
" </soap:Body>" +
"</soap:Envelope>" +
"";

var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");

xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Execute");
xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
xmlHttpRequest.send(xml);

var resultXml = xmlHttpRequest.responseXML;
alert(resultXml.xml);

}

No comments:

Split the String values with a special character in MS Flow to convert this into Array

 Many times we have a requirement to prepare the Mailing address for some of the documents, suppose there are Address Line1, Address Line2, ...