function CheckAccept()
{
Xrm.Page.getAttribute('new_filestatus').setValue(1);
TriggerWorkflow('pat_form1','7BA7F891-64D5-4414-894D-8698FF66F85E');
Xrm.Page.data.entity.save();
}
function TriggerWorkflow(entityName,workflowGuid) {
/*Generate Soap Body.*/
var soapBody = "" +
" " +
" " +
" " + Xrm.Page.data.entity.getId() + " " +
" " + workflowGuid + " " +
" " +
" " +
"";
/*Wrap the Soap Body in a soap:Envelope.*/
var soapXml = "
" 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 +
"";
/* 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);
}
Call this method like
TriggerWorkflow('entityname','7BA7F891-64D5-4414-894D-8698FF66F85E');
It will work.
If any issues just let me know.
Cheers!!