Sample Example
Function Demo () {
ID of the action record
var Targetid = "A8a46444-ba10-e411-8a04-00155d002f02";
Entity name of the action record
var targetType = "New_config";
The ID of the assigned user or team
var Assignid = "48025176-2b0e-e411-ba68-00155d002f02";
SystemUser or Team
var assigntype = "systemuser";
Assign (Targetid, TargetType, Assignid, Assigntype);
}
function Assign (targetid,targettype,assignid,assigntype) {
var request = "<s:envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">";
Request + = "<s:Body>";
Request + = "<execute xmlns=\"http://schemas.microsoft.com/xrm/2011/contracts/services\"";
Request + = "Xmlns:i=\"http://www.w3.org/2001/xmlschema-instance\">";
Request + = "<request i:type=\" b:assignrequest\ "";
Request + = "Xmlns:a=\"http://schemas.microsoft.com/xrm/2011/contracts\"";
Request + = "Xmlns:b=\"http://schemas.microsoft.com/crm/2011/contracts\">";
Request + = "<a:parameters xmlns:c=\"http://schemas.datacontract.org/2004/07/system.collections.generic\">";
Request + = "<a:KeyValuePairOfstringanyType>";
Request + = "<c:key>Target</c:key>";
Request + = "<c:value i:type=\" a:entityreference\ ">";
Request + = "<a:Id>" + Targetid + "</a:Id>";
Request + = "<a:LogicalName>" + TargetType + "</a:LogicalName>";
Request + = "<a:name i:nil=\" true\ "/>";
Request + = "</c:value>";
Request + = "</a:KeyValuePairOfstringanyType>";
Request + = "<a:KeyValuePairOfstringanyType>";
Request + = "<c:key>Assignee</c:key>";
Request + = "<c:value i:type=\" a:entityreference\ ">";
Request + = "<a:Id>" + Assignid + "</a:Id>";
Request + = "<a:LogicalName>" + Assigntype + "</a:LogicalName>";
Request + = "<a:name i:nil=\" true\ "/>";
Request + = "</c:value>";
Request + = "</a:KeyValuePairOfstringanyType>";
Request + = "</a:Parameters>";
Request + = "<a:requestid i:nil=\" true\ "/>";
Request + = "<a:RequestName>Assign</a:RequestName>";
Request + = "</request>";
Request + = "</Execute>";
Request + = "</s:Body>";
Request + = "</s:Envelope>";
execsoap (Request);
}
//Get service address
Function Getweburl () {
var serverurl = Xrm.Page.context.getServerUrl ();
if (Serverurl.match (/\/$/)) {
ServerURL = Serverurl.substring (0, serverurl.length-1);
}
return ServerURL + "/xrmservices/2011/organization.svc/web";
}
//Run request
Function Execsoap (request) {
var ajaxrequest = new XMLHttpRequest ();
Ajaxrequest.open ("POST", Getweburl (), true)
Ajaxrequest.setrequestheader ( "Accept", "Application/xml, Text/xml, */*");
ajaxrequest.setrequestheader ("Content-type", "text/xml; Charset=utf-8 ");
ajaxrequest.setrequestheader ("SOAPAction", "Http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute");
Ajaxrequest.send (Request);
}
CRM uses SOAP to assign records