For business management solutions email us or call 020 3004 4600
Transform the way you work by making it easier to use data across different cloud services through the use of Microsoft Flow without any code. Use a visual editor to specifically design a logical flow which automates routines which helps to improve your overall day to day efficiency. Microsoft Flows provides over 170 different connections including Dynamics 365 which can work in accordance with those of the in-app Dynamics 365 workflow editor.
In our latest tips and tricks article, we will show you how to use Microsoft Flow with Dynamics 365 for Customer Engagement. Within Microsoft Flow it has an action which is called ‘apply to each’ which allows you to loop through a set of records on the many side of a one-to-many of a relationship and interact with each of them.
To put this into a practical context, we have a requirement as a business that when the main phone number of an account changes, we would like to copy the account main phone number into the Company Phone field for all the related contacts. Previously, you would need code to do this because with a one-to-many relationship, like that of accounts to their related contacts, Dynamics 365 workflow processes couldn’t access existing records on the many side when the workflow is triggered from a record on the one side.
Don’t worry, this can be done with Microsoft Flow by following the below steps:
Step 1: Go to the Microsoft Flow website and sign in.
Step 2: From the main menu, select ‘My Flows’ on the left hand side then go to ‘New’ and choose the ‘Create from blank’ option.
Step 3: Once here, under the popular triggers tab select the ‘Dynamics 365 – When a record is updated’ option, if it isn’t here, use the search bar below to find it by typing ‘When a record is updated’ and select it.
Step 4: Under the ‘Organisation Name’ field choose the Dynamics 365 instance where you want the flow to be used.
NB: To be able to use the flow to trigger on the Dynamics 365 entity, the entity definition should have change tracking enabled
Step 5: Under the ‘Entity Name’ pick which entity you want this to apply to which will act as a trigger in initiating the flow. For the purposes of this example, we are going to choose ‘Accounts’.
Step 6: After you have completed the above, select ‘New Step’ and then add an action by typing in the search bar ‘List records’ and pick the corresponding option.
Step 7: Under the ‘Organisation Name’ field use the same Organisation Name as you did in Step 4.
Step 8: Under the ‘Entity Name’ field, pick which entity from which to list records when the event occurs. For the purposes of this example, select ‘Contacts’. After you have completed this, select ‘Show Advanced Options’.
Step 9: Click in the ‘Filter Query’ box. You will notice that a dynamic content pane appears to the right hand side where you are able to pick the fields from the previous steps. We will use an OData query to be able to filter the list to show active contacts related to the account which triggered the flow.
Step 10: Enter the following text into the ‘Filter Query’ box
Step 11: Next, from within the dynamic content pane, pick the ‘Account’ option (Description: Unique identifier of the account).
Step 12: After you have completed the above, select ‘New Step’ and then add an action by typing in the search bar ‘Update a record’ and pick the corresponding option.
Step 13: Under the ‘Organisation Name’ field use the same Organisation Name as you did in Step 4.
Step 14: Under the ‘Entity Name’ field, pick which entity from which to update a record when the event occurs. For the purposes of this example, select ‘Contacts’. After you have completed this, select ‘Show Advanced Options’.
Step 15: Click in the ‘Company Phone’ field. When the dynamic content pane opens to the right hand side pick the ‘Main Phone’ option (Description: Type the main phone number for this account).
NB: You can manually search for the Main Phone option in the search bar.
Step 16: Once you have completed the above, click in the ‘Record Identifier’ field and when the dynamic content pane appears select ‘Contact’ (Description: Unique identifier of the contact).
You will now see that Microsoft Flow has automatically nested the Update a record step within an Apply to each step. The apply to each action must reference output from a previous step and Microsoft Flow has automatically populated this with the dynamic content value which refers to the records from the List records step.
NB: You may wish to change this approach, as instead of creating the Update a record action first like we did above, you may want to first add and configure the Apply to each action and then proceed to add and configure a nested Update a record action).
Step 17: Simply click ‘Save’ once you have completed the above and you are done.
Test your newly created flow out by making a change to an account within Dynamics 365!
If you are looking for a complete Dynamics 365 solution for your business, looking to find out more about our Dynamics 365 training programs or want to discuss an upcoming project then please get in touch with Advantage today.
If you are looking to receive more articles similar to the above, then please feel free to sign up to our mailing list where you can get these types of articles delivered straight into your inbox.