Create and Update Dynamics 365 Child Records with Microsoft Flow

A client in the construction industry wanted to automatically create a new Project record in Dynamics 365 Customer Engagement when a project Quote was approved. They also wanted the custom Project record to inclde Products from the Quote, and put a lookup on the Products tied to the quote. Microsoft Flow turned out to be the perfect solution to their business need. Let’s Create and Update Dynamics 365 Records with Microsoft Flow.

We needed a way to update related child records (Quote Products) when something changed in the associated parent record (Quote Status). In the past, we would have achieved this via a custom workflow.  But with Microsoft Flow, you can make these kinds of updates without using any code! Using the “List Records” Action in Flow, we can list the related child records of the parent record and perform updates on those records as needed.

Here’s how to do it:

Flow Premium is required for the Flow Actions you need to achieve this.

1. Build a new automated Flow. Then select the “When a record is updated” trigger using the Common Data Service app. Using the CDS app instead of the Dynamics 365 app gives us the option to filter our trigger on specific fields. The Dynamics 365 app version of that trigger does not include field filter options.

Create and update Dynamics 365 Records with Microsoft Flow

2. Then select your environment, entity, and scope.  In this case, we are using the Quote entity to trigger the Flow from. In the Advanced Options, we’ve selected to trigger it when the status code changes.

Create and update Dynamics 365 Records with Microsoft Flow

3. Add a Condition Action to only run this Flow if the Quote Status = Won. When using option set fields in your conditions, you’ll need the numeric value that belongs to the label you are trying to use (4 = Won).

Create and update Dynamics 365 Records with Microsoft Flow

4. In the “If yes” side of the Flow, we have three Actions:

  1. Create a Project from the Quote
  2. List the related Quote Lines from the Quote
  3. Update Quote with a lookup to the Project

The approved Quote will be updated with a lookup to the Project that was created via Flow.

Create and update Dynamics 365 Records with Microsoft Flow

5. For creating the Project, we used the Create Record Action and we used the Name value of the Quote to name the Project by adding Dynamic content from the original Quote step in the Flow. We also added in a few other dynamics field values from the Quote on the Project.

Create and update Dynamics 365 Records with Microsoft Flow
Create and update Dynamics 365 Records with Microsoft Flow

6. For the List Quote Lines Step, use the List Records Action:

  1. Enter the environment and select the related child entity you want to list records for in this Flow.
  2. In the advanced options filter the child records accordingly in the Filter Query section. We are filtering the Quote lines for a specific product type (we have this field directly on the Quote line entity)
Create and update Dynamics 365 Records with Microsoft Flow

7. Insert another Update Record Action.

  1. Select the Environment.
  2. Select the related child entity you are updating.
  3. Select the record identifier for the entity you’ve listed in the previous step. In our case, the unique identifier for the Quote Lines is “Quote Product”.
Create and Update Dynamics 365 Records with Microsoft Flow

8. In the Advanced Options area, choose what you are updating on those related child records. In our case, we updated a link to the Project that was created via the Flow.

Create and update Dynamics 365 Records with Microsoft Flow

That’s it!  Now when a Quote is closed as Won, a project will be created AND the Quote will be updated with a lookup to the Project that was created via the Flow. No more workflow activity needed. That’s how you create and update Dynamics 365 Project records with Microsoft Flow.

Happy Flowing!

By Jessica Stansberry, Dynamics 365 Senior Application Consultant, Dyn365Pros, Microsoft Dynamics 365 Partner, San Diego, Southern California