Launch a Workflow from a button on a form
Making a system as user friendly as possible is always harder than we give it credit for. Sometimes end users need to trigger manual workflows in your solution. The standard Dynamics 365 way of doing this is to select off the ribbon the workflows option which then presents you with one of the least intuitive interfaces for selecting a workflow, I mean what is "Add" all about.
Problem
I would like to give an end user a friendly button they can click which appears when needed
Solution
Step 1 – You will need Ribbon Workbench, I prefer the one that sits in the XRM Toolbox, as it seems to run faster
Step 2 – Create a new “Command”
Step 3 – For the new Command we need to make it call our workflow
Give it an Action of “Custom Javascript Action”
Library = /_static/_forms/form.js
Function Name = Mscrm.FormAction.launchOnDemandWorkflowForm
Add a CRM Parameter
CRM Parameter = PrimaryEntityTypeCode
String Parameter = “GUID of the Workflow” (You can get this by editing your workflow, it’s in the URL)
Display Rules / Enable Rules = These are optional and control when it gets displayed, e.g. only appear when a certain field is complete. Very useful, I’ll write another aide-memoire on these.
Step 4 – Create a new button (Top option on the left)
Drag the button onto the ribbon were you want it to appear, I've included this one on the form
Select the command you just created from the drop down
Pick images for it, you can always create your own
Important
Leave the CommandCore value blank, this will autopopulate with the command name on publish
If you are having issues with display / enable rules not seems to take affect wipe the CommandCore value out and republish