web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Blogs / Innovating on CRM / Running Microsoft Flow from...

Running Microsoft Flow from within Dynamics 365 CE

CRMInnovation.com Profile Picture CRMInnovation.com

Wouldn’t it be great if you could trigger a Microsoft Flow from within the Microsoft Dynamics 365 CE? Well, we have been able to do that since the V9.0 release. Unfortunately there hasn’t been too much information about how to set this up and do it. If you go to the online docs and search for embed Flow in Dynamics 365 you will either get a page that shows you how to enable the Flow button for Dynamics 365 or this doc that sort of explains how to get a Flow to appear in the flyout menu within Dynamics 365.

But unfortunately, they are skimpy at best and in the case of the 2nd document listed, a little incomplete at best or a little incorrect as of the writing of this blog.

Here is the main piece of information you need to know.

Only Flows that start with the  COMMON DATA SERVICE TRIGGER WHEN A RECORD IS SELECTED will appear in the Flyout. Button Flows, Recurrence Flows or Flows that start with any other trigger type will not appear in the Flyout. Additionally, as you would suspect the Flow has to be enabled before it will appear.

Note: in a future blog post I will explain how you can get around this limitation of only Flows using ‘when a record is selected’ trigger.

Now to the fun part. I will show you a Flow I put together that a user can run from within Dynamics 365.

The scenario is that you want to be able to send a broadcast Text Messages (SMS) to Contacts on a Marketing List. We will use the 3rd party service Twilio and the existing standard connector to execute this process.

Here is what the Flow looks like (if it looks a little scrunched on your screen, click on it to get a bigger view):

Send Text Messages using Microsoft Flow

 

One of the challenges in creating this Flow is that there is a N:N relationship between the Contact entity and the Marketing List entity. And as a result we kind of have to do a double loop through the List Records Action to get the information from the List to the intermediary entity and then to the Contact.

Let’s break down each step of the Flow:

  1. When a record is selected – this is the first event in the Flow and this Trigger allows the Flow to appear in the Flyout. It is connected to the Common Data Service (CDS) behind the environment it is running in. It will also prompt the user to enter in the message they want to send to the SMS recipients.

Microsoft Flow When a Record is Selected Trigger

This is how the triggering event will present itself to the user. Pretty cool, Huh? Kind of like the old CRM Dialogs but not very pretty though,

Send SMS User Prompt

2. Get Marketing List – In this action we get info about the Marketing List we selected that we will use in later actions.

Microsoft Flow Get Marketing List

3. Using a Condition Check we make sure that we have selected a Marketing List that is of a Contact Type. If not it will send a failure notification to the user. Just a little sanity check that we didn’t pick a list that is composed of Accounts or Leads. Also, note that this Flow is assuming we are working with a Static list, modifying for it to use a Dynamic list will be blogged about in a future post. FYI, Contact is a record type ‘2’.

Microsoft Flow Conditional Logic

Since the dynamic value is a little cut off, here is the full name.

Microsoft Flow Marketing List Type

4. Now here is where we start dealing with the N:N relationship and it gets a little dicey. This would be so much easier if I was just demonstrating how to send a SMS message to a selected number of Contacts in a grid view. The first List records and  Apply to each is designed to get all the listmember records associated with the selected Marketing List. This is the intermediary entity relationship.

Microsoft Flow Retrieving N:N Relationship

5. Now that we have the records from listmember, we need to loop through and get all the Contact Records that are connected to the listmember records.

Microsoft Flow Retrieve N:N Relationship

6. Now the last step in data retrieval is to get the Contacts records themselves so that we can use attribute data from their records to send out the bulk SMS message.

Microsoft Flow Get Contact Attribute Data

7. Finally, we are ready to send out the SMS message. We will loop through each of the Contacts from the previous steps, grab their mobile phone number and send them an individual SMS.

Microsoft Flow Twilio SMS Connector

Wrap up – There is much room for improvement in this Flow. We should set it up so that it knows who the user is that is invoking it and using a Dynamic Value for the From Phone number and in the Condition logic the recipient shouldn’t be hard coded in the TO: email field, it should also be a Dynamics Value. We ought to be trapping for Contacts that don’t have a valid mobile phone number or who might have opted out of Text Messages. Saving some stuff for a future blog post.

The post Running Microsoft Flow from within Dynamics 365 CE appeared first on CRM Innovation - Microsoft Dynamics 365 Consulting and Marketing Solutions.

Comments

*This post is locked for comments