CRM 3.0 içinde Mitch Milam JavaScript ile nasıl workflow çalıştırabileceğimizi bize göstermişti. Fakat ExecuteWFProcessRequest sınıfı CRM 4.0'dan kaldırılmış, bu yüzden bu kod CRM 4.0'da çalışmıyor. Ama bu bizim için bir sorun değil bunu kullanabileceğimiz bir sürü yöntem var işte bunlardan birisi:
----
In CRM 3.0, Mitch Milam has described how to Launching a Workflow Rule from JavaScript, it works great. However, in CRM 4.0, the class: ExecuteWFProcessRequest has been deprecated,
so it won’t work in CRM 4.0. Although there are many ways to launch a
workflow, if you want to run it through JavaScript, here’s the trick:
/* the function
*/
ExecuteWorkflow = function(entityId,
workflowId)
{
var xml = "" +
"<?xml
version=\"1.0\" encoding=\"utf-8\"?>" +
"<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() +
" <soap:Body>" +
" <Execute
xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">"
+
" <Request
xsi:type=\"ExecuteWorkflowRequest\">" +
" <EntityId>" +
entityId + "</EntityId>"
+
" <WorkflowId>" +
workflowId + "</WorkflowId>"
+
" </Request>" +
" </Execute>" +
" </soap:Body>" +
"</soap:Envelope>"
+
"";
var
xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx",
false);
xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Execute");
xmlHttpRequest.setRequestHeader("Content-Type", "text/xml;
charset=utf-8");
xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
xmlHttpRequest.send(xml);
var
resultXml = xmlHttpRequest.responseXML;
return(resultXml.xml);
}
/* call */
var
theWorkflowId = "3FD2DD58-4708-43D7-A21B-F0F90A0AA9F2";
//change to
your workflow Id
ExecuteWorkflow(crmForm.ObjectId,
theWorkflowId);
8c4c7195-ce58-43f3-8ec9-d5da14d65177|0|.0
Dynamics CRM
microsoft, dynamics, crm, 4.0, microsoft dynamics crm 4.0, javascipt code, javascript, library, kolaylık, yazılım, geliştirme, software, workflow, launch workflow, executewfprocessrequest, executeworkflow