Call Microsoft Flow from Custom Ribbon Button

In one of my previous blog I mentioned how to use on demand flow within MS CRM. But we have some limitations with that approach

  1. we can’t apply Enable rules on the Flow button as it is OOB context menu which generates dynamically based on the number of flows.
  2. we can’t restrict a call to Flow to check the conditions whether Flow needs to run or not, I mean we can’t apply our conditions before a request goes to Flow.

the solution for the above problems is to call the Flow from custom ribbon button. To call a Flow from ribbon button, we have to create a flow on “HTTP Request” trigger. In my example I am creating a contact with First Name and Last Name fields and passing the parameters from ribbon button (as of now I am passing some constant values from my javascript). Here is the step by step process to do this

Step 1: Create a Flow with HTTP Request with proper “Request Body JSON schema” (use sample payload option to generate the schema)

Step 2: Add “Create a new record (Dynamics)” action to create a new Contact in CRM.

Step 3: Add a Response action at the end to send the response back to CRM and Save the Flow .

Step 4: Once your flow is created you will see the URL in the “HTTP Request” trigger. Use “HTTP POST URL” to trigger the Flow from ribbon button action (javascript).

Step 5: Create a ribbon button in CRM and call the below function from the ribbon button.

with this approach you can add all your validations in the java script and call the Flow once the conditions met, this way we can reduce lot of unnecessary calls to Flow. We can pass whole record context to Flow if needed. Hope it is interesting 🙂

4 thoughts on “Call Microsoft Flow from Custom Ribbon Button

  1. Hi Phani,

    Thanks for wonderful post. I was wondering whether do we need to generate the url once we push our changes from Dev to Prod envrionment ?

    Thanks

  2. Hi Phani,

    Thanks for the detailed information. Can you please give an example of how to maintain flow URL and Envrionment Variables and call the URL in JavaScript. This way would save hassle of changing flow URL.

    Cheers
    Bains

Leave a comment