// Example
Function demo (){
// Operation record ID
VaR targetid = "A8A46444-BA10-E411-8A04-00155D002F02 ";
// Object Name of the operation record
VaR targettype = "new_config ";
// 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: keyvaluepolicrofstringanytype> ";
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: keyvaluepolicrofstringanytype> ";
Request + = "<A: keyvaluepolicrofstringanytype> ";
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: keyvaluepolicrofstringanytype> ";
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 );
}
// Obtain the 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 ";
}
// Execute the 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 allocate records