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 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s