Call Workflow in CRM 2015 Easily from JavaScript Library

Paul Nieuwelaar, 12 August 2015

In the past if you've needed to call a workflow from JavaScript, you need to build a massive XML SOAP request making sure to pass in the correct attributes and conditions to get the request working.

This is tedious and messy, especially when there are many places you need to do this in a solution. It's also not good if something breaks in the future and you need to go back and fix up all instances of where the code is being used.

For these reasons, I've created a JavaScript library to make it easier to call processes, and to make the code manageable going forward. But most of all, it's so I don't have to keep finding the correct way to build the SOAP requests!
This library includes functions for calling workflows, actions, and even popping dialogs. For this blog post, I’ll just look at calling workflows. I’ll cover calling actions and dialogs in other posts.

To download the JavaScript library, check out the project on CodePlex:

Call Workflow

This function runs the specified workflow for a particular record asynchronously. Optionally, you can add callback functions which will fire when the workflow has been executed successfully or if it fails.

Parameters: Workflow ID/Guid, Record ID/Guid, Success Callback (function), Error Callback (function), CRM Base URL (not required on forms/views)

Process.callWorkflow("4AB26754-3F2F-4B1D-9EC7-F8932331567A",, function () { alert("Workflow executed successfully"); }, function () { alert("Error executing workflow"); });