Using Flow to Find and Update Lists of Related Entity Records

   Words by CRM Consultancy

   on 02/01/2020 14:04:00

I’m currently working with a charity to set up their CRM. One thing they need the ability do in CRM is claim Gift Aid against transactions. Gift Aid is a UK-wide programme whereby charities can receive an extra 25% on all charitable donations made by UK taxpayers.

For this process, we needed the ability to find all the donations where Gift Aid had not yet been claimed and pull these into a primary report to be checked. Then when the report has been checked and submitted to HMRC (The UK’s tax, payments and customs authority), we can mark all the Gift Aid transactions as completed, so they won’t be double counted in the next report.

Historically, using standard CRM workflows, listing/amending numerous related records was not possible without writing javascript.

Flow provides a no-code (or at least low-code!) solution to this, which is pretty straightforward to set up, and easy to maintain/troubleshoot further down the line.

1. CRM Set-up

Firstly, in CRM I created a new entity: ‘Gift Aid Process’. This is where the whole process will run from start to finish.

On this new Gift Aid process entity, we want to have two flows running; the first to find all the relevant transactions and link them to this entity to run the report from, the second to tick all the transactions as completed when the user has submitted their report to HMRC.

In this entity I created the following basic fields:

  • ‘Up To Date’ – the input parameter for our report.
  • ‘Process Run Date’ – will be updated by the flow automatically.
  • ‘Submitted’ – a boolean field, to kick off the second flow
  • ‘Submitted Date’ – will be updated by the second flow automatically
  • I also used the new auto-number functionality to set a standard unique reference code as the name field for my new Gift Aid process entity N.B. You need to make sure the name field is not business required, as the auto-number functionality works on first save of the record, so it will error on create in this case.

I then created a 1:N relationship between my Gift Aid process entity and my transaction entity, and added in a transaction subgrid to the Gift Aid process main form.

Now we can create our flow by navigating to ‘’. The best place to build Flow is from within a solution in Dynamics or PowerApps.


2. Flow Trigger

First we first define our trigger for the flow.

We select the required entity and the scope (exactly the same as with standard CRM workflows – usually we choose organisation here).

In this case I’m going to select ‘Create or Update’ and I want to run this when the ‘Up to Date’ contains data.


3. List Records

Here the goal is to find all relevant records based on the required criteria. There are a few ways of specifying the query, I’m going to use the Fetch Xml query to do this. In CRM I make my advanced find on my transaction entity with all the specifications I want (at this stage I set any variable fields as constant values – I’ll change these in a bit).


In your advanced find window, select the ‘Download Fetch Xml’ button on the top bar, and just paste the downloaded text file directly into the Fetch Xml Query field on the ’List Transactions’ step.

Then, for any variable fields, in my case ‘Up to Date’, you want to remove the constant value from the Fetch Xml text, and replace with the relevant field from your ‘Dynamic Content’ panel on the right hand side.


4. Apply to each

Here, to run a routine task on each record found in the previous step (transactions in this example) we must select ‘value’ from the dynamic content panel, in the ‘select an output from previous steps’ field.

We then want to add a new step under to define the action on each record. Here I am going to update, and I need to select the entity name and then define the Item ID using the dynamic content panel to find the ‘Transaction’ field.


5. Update listed records

Now we can set any field value in the entity, either statically or based on dynamic content. In my case, I simply want to link all my records to this Gift Aid process entity via a lookup, so that they are all visible in my subgrid, and so we can run a report on them.

To add a lookup value to a field when updating/creating a record in flow, we need to use the following syntax:

“Entity_Plural_Schema_Name(Entity ID)” where the Entity ID comes from the dynamic content panel.


When selecting your dynamic content, flow also splits out the fields into the separate flow steps so you can see clearly where your different dynamic field options are coming from.


6. Update original record

Here we are going to return to the original record (the Gift Aid process record) and update this accordingly to show the date the process was run.

We again have to specify the link back to the original record, specifying the entity and using the dynamic content to get the record ID.

Then I’m going to update the ‘Process Run Date’ using the expression utcNow, from the expressions panel on the right.


This is my final stage, so now we’re ready to save, test and make live!

This example just shows the first flow I mentioned, but my second one was very similar – I found that once I’d got the first one all perfected and tested, the second one fell into place very easily with just a few tweaks.

Working with flow is sometimes a bit fiddly at first, there are certain eccentricities to remember and there’s a lot of options to choose from at every stage. However, I’ve found it well worth putting the extra time in at the beginning to make use of all the functionalities of flow that you can’t get OOTB in any other aspect of Dynamics.

Share this Article

Search Articles

Filter Articles

CRM Tech DocMan

Recent Articles

HOW TO: Virtual Entities in Dynamics 365 Release Wave 2 New Feature: The Columns Button HOW TO: Search a date field in Microsoft Dynamics The Relevance Search COMING SOON to Power Apps Portals HOW TO: Manage Your Dynamics 365 Database Size (Video Included) Dynamics 365 Marketing vs ClickDimensions It’s time to pause, reflect and acknowledge a new era of inclusivity and collaboration. Part 2 - How to get the most from a Technology Expert – Asset Management Hub Property & Asset Management Hub Part 1 – Balancing CRM and Asset Management Scopes - Asset Management Hub Creating a Multi-Lingual PowerApps Portal How to Set Up a Microsoft Teams Site Using DocDrive365 Microsoft Teams - Adding a Microsoft Teams URL to a Dynamics Appointment Dynamics 365 Marketing – Customer Voice Survey Not Appearing In Emails? Using SQL Management Studio to connect to the Dynamics DB Calling a Power Platform AI Builder Model via oData How to use DocDrive365 to integrate permissions between Business Units in Dynamics with Sites in SharePoint Getting started with the Power Platform AI Builder. Power Apps Portal Information Hub DocDrive365 Security: Day One - Getting Started with Dynamics to SharePoint Permissions Part 5 - Power Apps Portals: How To Connect Azure B2C With Linked-In Part 4 – Power Apps Portals: Styling Azure B2C for Power Apps Portals The 3 Phases for Using Multi-Select Option Sets in Flow with Microsoft Forms Part 3 – PowerApps Portals: Azure B2C and Power Apps Portals – User Flow for Signup and Signin Part 2 - Power Apps Portals: New Application Registration in Azure B2C for our Power Apps Portal
Contact Us

Want expert advice or a demo?

Get in touch now and see how we can help your business grow.

  • Name
  • Email Address
  • Phone Number

Understanding Your Challenges

Our strong understanding of CRM and emerging technologies within the Microsoft environment means we deliver the right solutions for you.

Proven Real-World Solutions

As a leader in the field of Dynamics solutions, our pedigree developing and delivering real-world solutions is unsurpassed.

Long Term Support

We provide support beyond our design, implementation and 'go-live' delivery using Sprints and continual updates to our AppSource apps.

CRMCS | Design by Thinktank Marketing | Citrus-Lime Limited

To improve your experience today and in the future, this site uses cookies. Read our full Privacy Policy & Cookie information here I Understand