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.

  1. 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

  2. Extract the Workflow ID from the url and save for later.
  3. 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.
  4. Load the new solution into the Ribbon Workbench.
  5. 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

    Enable Rules
  6. 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
  7. 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.
  8. 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.
  9. 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

    Parameters1
  10. 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

    Parmeters2


    Adding the Buttons
  11. Select the 'Home Page' ribbon using the drop down in the top right of the design surface.
  12. Drag a new button on to the 'Process' Group

    Homepage button

    Give your buttons an image, and select the Command 'new.contact.Grid.RunWorkflow1.Command'
  13. Select the 'SubGrid' ribbon and drag a new button into the 'Process' Group

    Subgrid button

    Give your buttons an image, and select the Command 'new.contact.Grid.RunWorkflow1.Command'
  14. Select the 'Form' ribbon and drag a new button into the 'Process' Group

    Form Button

    Give your buttons an image, and select the Command 'new.contact.Form.RunWorkflow1.Command'
  15. Click 'Publish'.
  16. You will now be able to run your chosen workflow from the form and sub-grids and you will see the standard dialogs.

    run workflow

This no-code solution is great for quickly implementing those 'less-clicky' user requests!

Feedback and Knowledge Base