Why my script can't working ?
I want to execute workflow via javascript and called on button. but in my script, it can only stop at alert ("2.5");
function test() { alert("1"); GetBlastCreateWorkflow("Activate form LOO"); } function GetBlastCreateWorkflow(wfName) { alert("2"); var serverUrl = Xrm.Page.context.getClientUrl(); var odataselect = serverUrl + "/xrmservice/2011/OrganizationData.svc/WorkflowSet?$select=WorkflowId&$filter=ActiveWorkflowId/Id ne null and Name eq'" + wfName + "'"; alert("2,5"); $.ajax({ type: "GET", contentType: "application/json; charset=utf-8", datatype: "json", url: odataSelect, beforeSend: function (XMLHttpRequest) { XMLHttpRequest.setRequestHeader("Accept", "application/json"); }, success: function (data, textStatus, XmlHttpRequest) { RetrieveAndExecuteCreateWorkflow(Entity); }, error: function (XmlHttpRequest, textStatus, errorThrown){ alert('OData Select Failed:' + odataselect); } }); alert("2,75"); } function RetrieveAndExecuteCreateWorkflow(Entity) { alert("3"); var objFilteredWF = null; objFilteredWF = Entity; wfID = "5F808B14-AD18-4AB1-8E6B-A6A6FF399999"; if(objFilteredWF != null && objFilteredWF.result != null && objFilteredWF.result.length != 0 && objFilteredWF.result[0].WorkflowId != null) { wfID = objFilteredWF.result[0].WorkflowId; Process.callWorkflow(wfID, Xrm.Page.data.entity.getId() ); } }
*This post is locked for comments
Hi Ferdiansah,
Check this post, To execute workflow using Java-script.....
crmhub.blogspot.in/.../execute-workflow-using-java-script-MS-Dynamic-CRM.html
Hi,
Are you still using process.js ? Can you please check in console what errors are logged there? That will be more specific.
Thanks,
Sandeep
I used it once, but it still can not work. This is my script
Process.callWorkflow("B0612195-40B5-E711-8106-C4346BACAE18",
Xrm.Page.data.entity.getId(),
function () {
alert("Workflow executed successfully");
},
function () {
alert("Error executing workflow");
});
Hi,
You are using "Process.callWorkflow" function but looks like not using source library processjs.codeplex.com. This simple JavaScript library allows you to easily call workflows.
Please verify my answers.
Thanks,
Sandeep
It looks like you are passing parameters to SOAP request ,refer to below post for executing workflow from javascript using SOAP. You are using SOAP request but passing ODATA parameters which is not supported.
social.microsoft.com/.../how-to-execute-workflow-through-javascript-in-crm-2013
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,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156