我试图从网格中的功能区按钮运行工作流:
function TriggerWorkflow(entityId, workflowGuid)
{
debugger;
/*Generate Soap Body.*/
var soapBody = "<soap:Body>" +
" <Execute xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>" +
" <Request xsi:type=\'ExecuteWorkflowRequest\'>" +
" <EntityId>" + entityId + "</EntityId>" +
" <WorkflowId>" + workflowGuid + "</WorkflowId>" +
" </Request>" +
" </Execute>" +
"</soap:Body>";
/*Wrap the Soap Body in a soap:Envelope.*/
var soapXml = "<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'>" +
GenerateAuthenticationHeader() +
soapBody +
"</soap:Envelope>";
/* Create the XMLHTTP object for the execute method.*/
var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
xmlhttp.open("POST", "/MSCRMservices/2007/crmservice.asmx", false);
xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlhttp.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/Execute");
/* Send the XMLHTTP object. */
xmlhttp.send(soapXml);
}
但它确实抛出了一个异常:
GenerateAuthenticationHeader()
is undefined