latest Post

Dynamics CRM 365 WEB API Execute Workflow

As CRM developers we often find ourselves creating on demand workflows so that our users can perform some action as and when they need to. Unfortunately the user experience to do this OOB is not great selecting the ellipses >> Clicking Run Workflow, >> Choosing the workflow and clicking ok.



A much better solution to this is to add a button to the form ribbon and write the code to trigger the workflow from the button click. In the past to do this I have written A SOAP command to trigger the workflow from within JavaScript and those of you who have written SOAP envelopes know how tricky they can be. 
Fortunately in Dynamics 365 the Web API platform has been extended to allow you to trigger a workflow by simply calling the "execute workflow" method.  This is a lot simpler than doing this with SOAP.

Below is an example of triggering the workflow

Get Workflow GUID
 In order to easily find the workflow Name to use in the above helper method I wrote the below method to return the workflow GUID when given the work flow name.
Smart Buttons Ribbon workbench editor
An alternative solution to using the trigger workflow WEB API method above would be to use the latest version of the Ribbon Workbench which now includes Smart Buttons to allow you to call a workflow directly from the button without needing to write custom code to do this.  https://www.develop1.net/public/post/Smart-Buttons-in-the-Ribbon-Workbench.aspx

* Execute Workflow helper function expanded on from the following blog post on http://www.inogic.com.
Recommended Posts × +

0 comments:

Post a Comment