* You are viewing Posts Tagged ‘javascript’

Add an item to a CRM 2011 queue using javascript

Here’s a nifty little CRM2011 javascript function to add records of type targettype, with the uniqueindentifier, recordid, to a queue identified by queueid.

var addtoqueue_xmlHttpRequest = null;
function AddToQueue(targettype, recordid, queueid) {

var header = context.getAuthenticationHeader();
var target = “TargetQueued” + targettype; //http://msdn.microsoft.com/en-us/library/bb959372.aspx
var routetype = “Queue”;

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=\”” + target + “\”>” +
”          <EntityId>” + recordid + “</EntityId>” +
”        </Target>” +
”        <SourceQueueId>00000000-0000-0000-0000-000000000000</SourceQueueId>” +
”        <RouteType>” + routetype + “</RouteType>” +
”        <EndpointId>” + queueid + “</EndpointId>” +
”      </Request>” +
”    </Execute>” +
”  </soap:Body>” +
“</soap:Envelope>” +
“”;

addtoqueue_xmlHttpRequest = new ActiveXObject(“Msxml2.XMLHTTP”);
addtoqueue_xmlHttpRequest.Open(“POST”, “/mscrmservices/2007/CrmService.asmx”, … Continue Reading