Hi,
I need to call a workflow with input and output parameter from Javascript in MS CRM 2016.
I created the workflow and published but I am getting error as "Workflow should be published."
I republished, reset IIS but none made it work.
Please help.
Thanks.
*This post is locked for comments
Hi David Jennaway,
Thanks. Your response is the correct answer. Even though I have only one workflow with that name CRM internally maintains multiple copies of the same workflow.
Getting the workflow with activeworkflowid is not null is the correct one.
Thanks.
try to get your workflow id from address bar internet explorer, when your workflow open in a form on the address bar at the end of your workflow guid is there
Is the exact error you are getting: "workflow must be in published state"?
If it is, see the following:
It is not part of my form script. It is separate Library. I have shown the function I am calling and how I am calling, I want to know if there is any wrong in the calling script.
Hi Jayakumar,
If you are using the library, then why do you have the entire request in as part of your code. It is unnecessary. The only thing that you need is the part that you specify in Finally...
Aric
Hi Aric,
I am using the same library only. See the code above I posted.
Thanks.
For calling the workflow, you can download the process.js project. This provides you with easy to use functionality for calling Workflows and Actions in CRM.
Link is: https://processjs.codeplex.com
Good luck.
Its a custom workflow. I removed the input parameter because I don't know how to pass input parameter in the SOAP XML. But still the same issue after removing the input parameter.
Hi Ahmet,
This is the library I am using for calling the workflow.
Process.callWorkflow = function (workflowId, recordId, successCallback, errorCallback, url) {
debugger;
if (url == null) {
url = Xrm.Page.context.getClientUrl();
}
var request = "<s:Envelope xmlns:s='schemas.xmlsoap.org/.../&;>" +
"<s:Body>" +
"<Execute xmlns='schemas.microsoft.com/.../Services&; xmlns:i='www.w3.org/.../XMLSchema-instance&;>" +
"<request i:type='b:ExecuteWorkflowRequest' xmlns:a='schemas.microsoft.com/.../Contracts&; xmlns:b='schemas.microsoft.com/.../Contracts&;>" +
"<a:Parameters xmlns:c='schemas.datacontract.org/.../System.Collections.Generic&;>" +
"<a:KeyValuePairOfstringanyType>" +
"<c:key>EntityId</c:key>" +
"<c:value i:type='d:guid' xmlns:d='schemas.microsoft.com/.../&;>" + recordId + "</c:value>" +
"</a:KeyValuePairOfstringanyType>" +
"<a:KeyValuePairOfstringanyType>" +
"<c:key>WorkflowId</c:key>" +
"<c:value i:type='d:guid' xmlns:d='schemas.microsoft.com/.../&;>" + workflowId + "</c:value>" +
"</a:KeyValuePairOfstringanyType>" +
"</a:Parameters>" +
"<a:RequestId i:nil='true' />" +
"<a:RequestName>ExecuteWorkflow</a:RequestName>" +
"</request>" +
"</Execute>" +
"</s:Body>" +
"</s:Envelope>";
var req = new XMLHttpRequest();
req.open("POST", url + "/XRMServices/2011/Organization.svc/web", true);
req.setRequestHeader("Accept", "application/xml, text/xml, */*");
req.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
req.setRequestHeader("SOAPAction", "schemas.microsoft.com/.../Execute");
req.onreadystatechange = function () {
if (req.readyState == 4) {
if (req.status == 200) {
if (successCallback) {
successCallback();
}
}
else {
if (errorCallback) {
errorCallback();
}
}
}
};
req.send(request);
}
Finally, I am getting the workflow Id from CRM and calling the workflow.
"/api/data/v8.2/workflows?$select=workflowid&$filter=name eq 'Test Workflow'
var workflowId = workflow[0].workflowid;
var recordId = Xrm.Page.data.entity.getId();
Process.callWorkflow(workflowId, recordId, SuccessCallBack, ErrorCallBack);
Yes. Activated. Auto triggering is working based on field update. Only calling from JavaScript not working.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156