Route a QueueItem from one Queue to Another Queue using SOAP Code in MS CRM 2011

Route a QueueItem from one Queue to Another Queue using SOAP Code in MS CRM 2011

Some times we may need to route manually queue item to our personal queue on ribbon button click.

Call the below function on custom ribbon button to assign a queue item to your personal Queue or any other queue by passing the Source Queue guid , Destination queue guid and Queueitem guid.

function AssignEmialToQueueUsingEmailGuid(sourceQueueid ,SystemUserPersonalQueueGuid, QueueItemGuid) {
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=\”TargetQueuedEmail\”>” +
” <EntityId>” + QueueItemGuid + “</EntityId>” +
” </Target>” +
” <SourceQueueId>” + sourceQueueid + “</SourceQueueId>” +
” <RouteType>Queue</RouteType>” +
” <EndpointId>” + SystemUserPersonalQueueGuid + “</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&#8221;);
xmlHttpRequest.setRequestHeader(“Content-Type”, “text/xml; charset=utf-8”);
xmlHttpRequest.setRequestHeader(“Content-Length”, xml.length);
xmlHttpRequest.send(xml);

var resultXml = xmlHttpRequest.responseXML;
alert(“A Queue Item is Successfully Routed to Your Queue”);
}

Regards,

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s