Support Portal ContactGet in touch

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

CRMCS Quick Start Guide: How To Produce a Microsoft Teams Live Event Dynamics 365 Marketing: Lead Scoring and Sales Acceptance Designing and Developing Microsoft Power Apps Portals Thank You for Attending CRMCS’ Webinar - Achieving B2B sales excellence with Dynamics 365 & Microsoft Teams Thank You for Attending Our Webinar - Achieving B2B sales excellence with Dynamics 365 & Microsoft Teams Webinar: Discover How CRMCS Have United Dynamics 365, SharePoint and Microsoft Teams To Create Sales Excellence Ignite your workflow by adding DocDrive365 to Office 365 The CRMCS guide to everything you need to know about integrating Teams with Dynamics 365 Saving Time By Keeping Documents In One Place TDE Database Encryption with On Premise Dynamics The Key to Successful Compliance in 2020 Part 2: Let’s get GDPR Compliant with Microsoft Power Automate Top 3 Essential Tips for Remote Working Dynamics 365 Marketing: Top 5 Best Features Dynamics Day in the Life - Puma Investments Can you use Teams to amplify collaboration in Dynamics? Part 1: Using a Scheduled Power Automate to Trigger Expiry Date Reminders The secrets of successful document collaboration in Dynamics CRMCS launches new AppSource approved DocDrive365 Dynamics Day in the Life - Moneypenny Release Management Add the App to Dynamics DocDrive365 Security: Day One - Getting Started with Dynamics to SharePoint Permissions Building a New Scheduled Process using Flow
  • "Paul has made a real difference to how my team of 24 people record and store valuable customer data and sales opportunities. Highly recommended."

    James, Operations Director

  • "Understanding your business allows us to advise when to implement aspects of CRM and, likewise, when not to."

    Paul McQuillan, Managing Director

  • "Dynamics 365 and CRMCS have made a real lasting difference to our business, allowing us to replace older systems that were holding back our performance."

    Grahame, Chief Operating Officer

  • "James worked well with us to help connect CRM with Outlook and relate how this might benefit our team using CRM for Property Care."

    Natalie, Property Care Supervisor

  • "Matt was really good with helping us run User Testing on the new Compliance Module of our CRM System."

    Tom, Compliance Administrator

Prefer to go old-school?

Write to us using the below addresses.

Head Office
CRM Consultancy
61 Oxford Street
M1 6EQ

London Office
CRM Consultancy London
Grosvenor Avenue

Content © CRM Consultancy.