Create a Workflow Short Cut Ribbon Button (No Code Solution!)
Challenge:
Don't you find users are always complaining about the 'number of clicks' it take to do things? Although, the standard Run Workflow button provides a lookup to find a particular workflow to run, it would be nice to provide 'short-cut' buttons to run commonly used workflows.
Solution:
There are many solutions posted that involve using JavaScript webresources to perform this, however there is a much easier way that requires no-code! This method uses the existing JavaScript and has the benefit of providing the same user experience as you see when using the out of the box functionality.
The following solution demonstrates adding a 'short-cut' to a
Workflow already created on to the Contact form and grids. The Grid
button will run a workflow on the selected records.
- Open the Process Centre Workflow in the designer and press
'F11' to show the address bar - then copy the URL.
It should look something like:
http://<Server>/<OrgName>/sfa/workflow/edit.aspx?id=%7b<WorkflowID>%7d
- Extract the Workflow ID from the url and save for later.
- Create a solution and add the Contact Entity along with the
ribbon button images that you want to use on your button. See
the Getting Started Guide for more information on buttons.
- Load the new solution into the Ribbon Workbench.
- In the 'Solution Element' panel, add the following
EnableRules and mark each one as 'IsCore=True' in the
properties.
-Mscrm.SelectionCountAtLeastOne
-Mscrm.RunWorkflowSelected
-Mscrm.FormStateNotNew
-Mscrm.RunWorkflowPrimary
- Under 'Commands' in the Solution Elements Panel, add two
Commands and name them something like:
-new.contact.Form.RunWorkflow1.Command
-new.contact.Grid.RunWorkflow1.Command
- Right-Click on the Command
'new.contact.Form.RunWorkflow1.Command' and select 'Edit Enable
Rules'
Add the following Enabled Rules:
-Mscrm.FormStateNotNew
-Mscrm.RunWorkflowPrimary
This will ensure that the button is only enabled if workflows can be run on the current record.
- Right-Click on the Command
'new.contact.Grid.RunWorkflow1.Command' and select 'Edit Enable
Rules'
Add the following Enabled Rules:
-Mscrm.SelectionCountAtLeastOne
-Mscrm.RunWorkflowSelected
This will ensure that the button will only be enabled if there are records selected and they can have workflows run on them.
- This is where the magic happens:
Right-click on the Command 'new.contact.Grid.RunWorkflow1.Command' and select 'Edit Actions'
Add a JavaScript Command and set the following properties:
Function Name Mscrm.GridRibbonActions.launchOnDemandWorkflow Library /_static/_common/scripts/RibbonActions.js Parameters 1: Type = Crm Parameter, Value = SelectedControl
2: Type = Crm Parameter, Value = SelectedControlSelectedItemReferences
3: Type = Crm Parameter, Value = SelectedEntityTypeCode
4: Type = String, Value = Workflow ID found from the URL in the previous steps
- Rigth-click on the Command 'new.contact.Form.RunWorkflow1.Command'
and select 'Edit Actions'
Add a JavaScript Command and set the following properties:
Function Name Mscrm.FormAction.launchOnDemandWorkflowForm Library /_static/_forms/form.js Parameters 1: Type = Crm Parameter, Value = PrimaryEntityTypeCode
2: Type = String, Value = Workflow ID found from the URL in the previous steps
Adding the Buttons
- Select the 'Home Page' ribbon using the drop down in the top
right of the design surface.
- Drag a new button on to the 'Process' Group
Give your buttons an image, and select the Command 'new.contact.Grid.RunWorkflow1.Command'
- Select the 'SubGrid' ribbon and drag a new button into the
'Process' Group
Give your buttons an image, and select the Command 'new.contact.Grid.RunWorkflow1.Command'
- Select the 'Form' ribbon and drag a new button into the
'Process' Group
Give your buttons an image, and select the Command 'new.contact.Form.RunWorkflow1.Command'
- Click 'Publish'.
- You will now be able to run your chosen workflow from the
form and sub-grids and you will see the standard dialogs.
This no-code solution is great for quickly implementing those 'less-clicky' user requests!