Microsoft Flow – Dynamics 365


Microsoft Flow Prerequisites
What is Microsoft Flow?
Microsoft Flow Licensing
Microsoft Flow Access

Microsoft Flow Setup
Microsoft Flow Triggers
Microsoft Flow Actions – Create a new record
Microsoft Flow Actions – List records
Microsoft Flow Actions – Delete a record
Microsoft Flow Actions – Get record
Microsoft Flow Actions – Update a record

Microsoft Flow Dynamics 365 Tips & Tricks
Conditions (Control)
OData Queries for lists or get records
Dynamic String Fields
Composing a list of associated records

Microsoft Flow Prerequisites

What is Microsoft Flow?

Microsoft Flow is cloud-based software tool that allows users the ability to automate actions across multiple applications and services. Flow, like Dynamics 365 workflow, automates the repetitive tasks within an organization to simplify user experience while still ensuring business guidelines are followed.

Each flow has a single trigger action that starts the flow, followed by conditions and other actions that determine specific events. Because there are multiple applications each flow can trigger and write to (list seen here), I will be focusing on only the Dynamics 365 connectors and the possibilities within each.

Microsoft Flow Licensing

Microsoft Flow licensing is offered within four plans, namely;

  • Flow Free

This product license is available to all non-365 users and offers a maximum of 750 runs per user per month, with a maximum flow frequency of 15 minutes.

The restriction within this plan is that you cannot share any connections or custom connectors with other members within your company nor is there any offered SLA.

  • Flow for Office and Dynamics 365

This product license is available to all office 365 and dynamics 365 users, offering a maximum of 2,000 runs per user per month, with a maximum flow frequency of 5 minutes. Included in this plan and all other additional plans is an SLA.

  • Flow Plan 1

This product license is available at a starting cost of $5 per user per month.

It offers a maximum of 4,500 runs per user per month, with a maximum flow frequency of 3 minutes.

  • Flow Plan 2

This product license is available at a starting cost of $15 per user per month.

It offers a maximum of 15,000 runs per user per month, with a maximum flow frequency of 1 minute.

This is the only plan that allows for viewing flow usage across your company and use of the business process flows to model multi-stage processes.

Plan 2 can be trialed through a free 90-day trial should you wish to test out any Flow functionality before purchasing a subscription.

In each plan, there is no restriction on the number of flows you can setup, only on the number of flows per user per month. Once that collective pool is used up, no more additional flows will be triggered until the cap is reset at the end of the month. That means that, while each user is allocated a certain number of flow runs, all flow runs are allocated into a single pot for the entire instance. This means that each trigger is not user bound, but triggers from an organizational level. Meaning, if your trigger is Update of a record, then each time the record is updated, a flow will be triggered. Hence, flow is not meant to replace Dynamics 365 workflow and should only be used in situations where Dynamics 365 workflows are limited.

If the cap is reached, you can buy additional runs on top of your existing quota: for every 50 000 runs, an additional $40 is required.

For a more in-depth analysis into what each plan offers, please consult the Flow pricing website.

Microsoft Flow Access

To begin using Microsoft Flow, simply log into Microsoft Flow or Office 365 and choose to open Microsoft Flow.

Once authenticated, you will have access to articles and videos that will assist you in familiarizing yourself with Flow setup and features, including templates and the mobile app links.

Microsoft Flow Setup

Once you’ve logged in, the home screen will present you with a a set of possible templates. Look through each of the templates available to see if there is a template that already matches your requirement.

However, should you wish to start from blank, click on the My Flows button and click on the Create from blank button.

The very first place to start is to give the new flow a name. To do this, click on the Untitled text box and give the flow an adequate name.

Then its time to set the trigger that starts the flow. To state this again, I will only be looking through the Dynamics 365 triggers and actions to give you a list of actions and triggers available to all Dynamics 365 flow users.

Microsoft Flow Triggers

Firstly, enter in the name of the application you wish to trigger from; Dynamics 365. Then select one of the available triggers under the trigger tab:

  • When a record is created
  • When a record is deleted
  • When a record is updated
  • When a record is created or updated

(Note: Preview exposes the option sets as strings)

Keep in mind that these triggers are at an organizational level, meaning, you cannot set the trigger to a specific field, but at an entity level. This means that if you choose the Update trigger, flow will trigger each time any field on the entity record is updated.

Selecting one of the trigger will then ask you to supply the instance and the entity the trigger must be connected too.

For those that use sandbox and a production, this means that you will need to setup a flow for both instances as each flow only operates within a single instance, but the pool is seen across all instances.

That’s not to say that you have to recreate the flow for each instance, you can use the Save As option on the flow and then change the organization name without having to change anything else. Obviously, if the fields are different, then you will need to update those mappings as well.

Once an organization and entity has been selected, click on the New Step button to add either of the following actions:

  • Create a new record
  • List records
  • Delete a record
  • Get record
  • Update a record

(Note: Preview exposes the option sets as strings)

For the next few sections, I will work through each action to ensure you are able to work with the action that best suits your requirement.

Microsoft Flow Actions – Create a new record

This action is self explanatory. Based off the trigger, you can decide to create another record and include mappings from the trigger should you wish.

Within each new create a new record, there is a Show advanced options button. Clicking on this will open all other non-required fields.

There you can add any values to any of the fields available.

Microsoft Flow Actions – List records

This action allows a list of records to be fetched and influenced should you need too.

For example, if you wish to get each contact under a single account and then associated another action to that same list, you can do so by first using this action.

Obviously, without adding a filter, the list records action will fetch all contacts.

To do this, enter in the following filter: _ID_value eq {Unique Identifier}

For example, if you wish to bring back a list of quote products associated to a quote, you will set:

(_quoteid_value eq {Quote Unique Identifier})

You can include additional filters by adding an AND statement between the queries, for example:

statecode eq 1 and _quoteid_value eq {Quote}

Then, based off the list, you can run another update a record action which will then apply to each record returned from the list records action.

Simply add the List Records contact unique identifier to the Record Identifier field.

The resulting action means that each update will be applied to each record found within the list of records returned from the query.

This way, you could potentially set the accounts address, main phone and contact preferences to each contact connected to this account.

Microsoft Flow Actions – Delete a record

This action is also very simply, using this action will delete the record where the identifier matches the unique identifier.

Microsoft Flow Actions – Get record

This action is incredibly useful when it comes to getting details from other associated records. The specific use case is when you wish to bring through details from a lookup field, like getting the Owner full name instead of having the Guid. To do this, add a Get Record action and pass through the item identifier.

Once you’ve done this, post this action, all the fields available to this entity and record based off the Guid will be referenceable.

Microsoft Flow Actions – Update a record

If you need to update a record, use this action to do so. You can reference other actions (get record or list records) when attempting to use this update action.

Microsoft Flow Dynamics 365 Tips & Tricks

While the amount of actions at the time of writing this blog are limited to the above, using multiple actions together can allow for almost any flow setup to meet any requirement.

I have setup the following list of tips and tricks you can use in setting up your flows.

Conditions (Control)

Conditions are great for when you want to compare certain values and set the flow to run down two different streams depending on if the field(s) are either true or false.

For example, you can state that if an account [account type] is a customer type, then run down the Yes/True path, otherwise, run down the No/False path.

You can also setup multiple conditions using the and expression, for example:

@and(lessOrEquals(triggerBody()?[‘FIELDSCHEMA‘], 10),equals(triggerBody()?[”FIELDSCHEMA‘], true))

That way you can add as many conditions to the @and statement as you’d like and build as big a flow as you require based on certain conditions.

OData Queries for lists or get records

There will be instances where you need to fetch a list of records from a particular data source and apply a filter to ensure the list doesn’t return every record from that source.

Here are the list of OData queries I’ve found to be quite helpful over time:

Equals –> eq

Equals null –> eq null

Not null –> ne null

Starts with “String” –> startswith(Mapping,’Str’)

Ends with ‘String’ –> endswith(Mapping,’ing’)

Length of a string –> length(Mapping) gt 50

Contains “Text” –> Contains(Mapping,’Test’)

Greater than –> gt

Greater than or equal to –> ge

Less than –> lt

Less than or equal to –> le

If there are multiple filters you wish to add, simply add “and” or “or” between each, i.e. Mapping1 eq “Test” and Mapping2 eq “Test2”


If you need to set the lookup mapping, you must have the following on hand:

  • The unique identifier of the record you are dynamically mapping
  • The name of the entity you are mapping through

For example, I want to create a new task when a new account is created, but also have the task set to the account so that I can view it from the account as the source of the task.

To setup this up, I will need to find the unique identifier of the record (normally the name of the entity in Dynamics 365) and then I will need to set the type of record I am mapping through.

Dynamics String Fields

Should you wish to dynamically include Dynamics 365 field data into a string field (like you would using Dynamics 365 workflows), select the string field you wish to update and enter in the default text before adding a dynamic value.

Then, select the area you wish to input the dynamic value, search for and select the input.

Each time this new task is created, the account name will be dynamically set into the subject line.

Keep in mind that if you do not use the preview action, the option set values will be inserted into the text boxes. Also, try stay away from lookups, as the Guid of the record will be inserted instead of the primary field of the record (ie. Account name).

If you wish to bring through fields from another record, like the account name, then you will need to use a Get Record action before using this method so that the account name is available.

Composing a list of associated records

Should you ever need to list a set of records from a List Records action, you can do so using one of the two table actions:

  • Data Operations – Create CSV table
  • Data Operations – Create HTML Table

While HTML tables are great for inserting into an email, you cannot always use them in an update action as they will contain the HTML divs.

To bypass this, I will show you how you can still create a custom table outside of the Custom columns option available within each of the above tables.

To start, use the List Records action to gather a list of records from Dynamics 365. Then, add another action under the data operations called Select. There you will pass through the value from the list and map each of the returned values into a section of its own.

In this example, I will be creating a list of quote products from a single quote to add to an approval record.

Once you’ve setup the mapping, choose to add another data operations action, except this time use the data operations Create CSV Table action. Pass through the output of the selection action above into the from field and choose to include headers.

Finally, because it is a CSV table, it will be including the ‘,’ characters. To remove these character, add a data operations compose action, then add the following expression into it: replace(body(‘TABLENAME‘),’,’,”)

Now, all you have to do is pass through the output of the above into any update or approval action and the custom list will be displayed like so on a mobile device:


The Approval action is a powerful action that utilizes both Office 365, Flow mobile app and Dynamics 365.

To begin, add a new action and search for the Approval action.

Once you’ve selected it, begin entering the required fields:

  • Approval Type
    • Anyone from the assigned list
    • Everyone from the assigned list
  • Title
  • Assigned to (must be an email address). Note you can use multiple email addresses, simply separate them by using a ‘;’

Here you can see that you can use mappings from previous get record actions and the Output as the list of records.

Should you require a link to the actual record in Dynamics 365, make sure you either build the url through other compose data operations or store the record url into the record via workflow OnCreate.

Following the approval request, an email and a flow mobile notification will be sent to the Assigned To recipients. Following their response, you can set another condition that takes that response and uses it to send an email to the approval requester and/or updates the record that the approval request came from.

If there are multiple approval assignee’s, you will need to add an additional condition that checks the email of the approval reviewer and sets the user ID (manually fetched from Dynamics 365) into any lookup that might need to reference who approved/rejected the approval.

How to format a flow email in HTML

There are instances where customers require flow email notifications be in HTML or at least formatted better with signatures etc. The only post that helped me solve this was David Lozzi’s post. Use this post to help solve this issue.