Código Jscript para Cambiar Estado a un Registro usando Jscript para CRM 2011:

   1: function SetState(EntityName,Id,State,Status)

   2: {

   3:     var authenticationHeader = GenerateAuthenticationHeader();

   4:     // Prepare the SOAP message. 

   5:     var xml = "<?xml version='1.0' encoding='utf-8'?>" +

   6:  

   7:     "<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'" +

   8:     " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>" +

   9:     authenticationHeader +

  10:     "<soap:Body>" +

  11:     "<Execute xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>" +

  12:     "<Request xsi:type='SetStateDynamicEntityRequest'>" +

  13:     "<Entity>"+

  14:     "<Id xmlns='http://schemas.microsoft.com/crm/2006/CoreTypes'>"+Id+"</Id>" +

  15:     "<Name xmlns='http://schemas.microsoft.com/crm/2006/CoreTypes'>"+EntityName+"</Name>" +

  16:     "</Entity>" +

  17:     "<State>"+State+"</State>" +

  18:     "<Status>"+Status+"</Status>" +

  19:     "</Request>" +

  20:     "</Execute>" +

  21:     "</soap:Body>" +

  22:     "</soap:Envelope>";

  23:     

  24:     // Prepare the xmlHttpObject and send the request. 

  25:     var xHReq = new ActiveXObject("Msxml2.XMLHTTP"); 

  26:     xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false); 

  27:     xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Execute"); 

  28:     xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8"); 

  29:     xHReq.setRequestHeader("Content-Length", xml.length); 

  30:     xHReq.send(xml); 

  31:     // Capture the result. 

  32:     var resultXml = xHReq.responseXML;

  33:     

  34:     // Check for errors. 

  35:     var errorCount = resultXml.selectNodes('//error').length;

  36:     if (errorCount != 0) 

  37:     { 

  38:     var msg = resultXml.selectSingleNode('//description').nodeTypedValue; 

  39:     alert(msg); 

  40:     }

  41: }