Run Workflow directly from a button in Dynamics 365 Customer Engagement V9.0

Introduction:
In this blog we will demonstrate how to call a workflow directly from a button without any custom JavaScript code.

Implementation:

Step 1: Create the required workflow. In this example i have created a  simple workflow on the opportunity and remember to select the  “As an on-demand process” option.

Step 2: After the workflow is created store the GUID of the workflow. To get the GUID select the workflow and copy down the ID from the URL as shown in the below image.
Get Workflow GUID

Step 3: Now create the custom button on Opportunity entity using Ribbon Workbench.
Step 4: Create a new Command and click on “Add Action>JavaScript Action” as shown in the image.
Creating New Command

Step 5: In the library option write the following “/_static/_forms/form.js” and in the Function Name field “Mscrm.FormAction.launchOnDemandWorkflowForm“.
Setting up Functions
Then as shown in the above image add two Parameters as follows:
  1. Crm Parameter = PrimaryEntityTypeCode
  2. String Parameter = “GUID of the Workflow”.

Step 6: For the final step add the command to the newly created button by simply selecting it from the drop down in the properties section.

Selecting Command for the button


 Step 7: Now when we click on the button that we created we get the following message.
Run Workflow


On clicking OK the workflow will run. This is  helpful as it can be done quickly without using any custom code.

Comments

Popular posts from this blog

Create and Associate Records in a single operation using Xrm.WebAPI in D365 Customer Engagement

Use Audit Logs in Dynamics 365 : Actionable Audit