Launch a Workflow from a button on a grid
Previously I discussed to launch a workflow from a form, today i'll extend this to make it work from a grid.
Problem
I would like to give an end user a friendly button they can click which appears when needed on either the sub grid or main grid
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/_common/scripts/RibbonActions.js
Function Name = Mscrm.GridRibbonActions.launchOnDemandWorkflow
Add a CRM Parameter, CRM Parameter = SelectedControl
Add a CRM Parameter, CRM Parameter = SelectedControlSelectedItemReferences
Add a CRM Parameter, CRM Parameter = SelectedEntityTypeCode
String Parameter = “GUID of the Workflow” (You can get this by editing your workflow, it’s in the URL) or using the API as per the previous article "Dynamics 365 Quick way to get a record's guid, and what the source data looks like",
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
The order of the parameters is important in the Command
Comentarios