Part 1: Using a Scheduled Power Automate to Trigger Expiry Date Reminders

   Words by CRM Consultancy

   on 10/07/2020 10:57:00

Microsoft Flow Logo

At the moment we are working with a charity who collect Gift Aid on donations. The donor has to sign a Gift Aid declaration so that the charity can
claim this back on their behalf. These declarations expire after some time, so one goal our CRMCS Consultant Jess wanted to achieve here was to
set up an automatic task reminder system, so that the charity could always keep up to date with these Gift Aid declarations.

Initially, our we created a timeout workflow to generate these tasks, but after some thought and a discussion with one of my co-workers, we realised this was going
to be a bit of a ham-fisted way of solving the problem. 

The Gift Aid declarations are valid for a number of years, so while this would have technically worked, it would mean leaving a lot of workflows on wait conditions for
a long time, and then also needing to have another set of checks in the workflow/a 2ndchild workflow to ensure none of the original parameters had changed during the wait.

We wanted to find a better solution to this problem. Jess hadn’t had much (successful) experience using flow previously, so I didn’t jump to this option straight away, but with the help of Paul McQuillan and some useful blog articles online, we decided to give it a go…

1. Creating Flow: Set Schedule

With flow we can set up a scheduled workflow to run on a regular repeating basis, something not possible previously in Dynamics without using Javascript.
To create a new flow, we navigate to and go to our solution or ‘My Flows’ tab on the left, then I’m going to select new ‘Scheduled - From blank’.


This takes us to the recurrence screen, to define the starting date of our flow, and the recurrence – the options here are pretty flexible, you can set recurrence every second, to every month, and also with options for multiple days in a week.


2. List Records

I want my flow on a weekly basis to search the database for any contact whose Gift Aid declaration will be expiring in 4-5 weeks time. To find all records using this criteria, we use the ‘List Records’ action.
First you need to click ‘New Step’ under your recurrence step, and then find the connector ‘Common Data Service (Current Environment)’
N.B. Confusingly, there is also one connector called ‘Common Data Service’. When they appear in the list, hover over to check you’ve got the right one!


You should then find the ‘List Records’ action under this connector, and select the relevant entity (Contacts in my case).

3. Filter Records

There are a few different ways to filter records using flow here. I’m going to use the Fetch XML method for this.

To do this, go to your Dynamics environment, create an advanced find with all the required criteria.

  N.B. If you want to use any of the fields from your entity later on in the flow, you will need to add those field to the column list in your advanced find! I know this from some frustrating experience…

  For variable fields that you want to be dynamic in the query (in my case the expiry date), just add them as a set value in the advanced find, and we’ll change it in the next step.



Once you’ve completed your advanced find, click ‘Download Fetch XML’ and paste this directly into the Fetch Xml Query field on the ’List Contacts’ step. (If you’re using this, you can bypass all the fields between Entity name and this one.)



In order to make your query dynamic, you now need to change the fields that were set in the advanced find. To do this, just delete the hard coded value from within the query, then click the ‘Add Dynamic Content’ button in its place.

E.g. <condition attribute="crmcs_giftaidvaliduntil" operator="on-or-after" value="01/07/2020" />

Flow gives you some helpful suggested functions for each field type in the ‘expressions’ tab – I’m using the following addDays function to set the two parameters between 28 days and 35 days in the future. The utcNow function pulls in the current date-time stamp from when the flow runs.


4. Add Task to Every Selected Record

To run a follow-up action on every listed record, you now need to add a new step to your flow and find the ‘Apply to each’ action.

In the ‘Select an output from previous step’, you should add the ‘value’ field from the dynamic content section, then add a new step for ‘Create a new record’ – I’m going to use the task entity.

Here you can either set hard-coded or dynamic field values based on previous flow steps. I’m going to use a hard coded subject and description field, and dynamic fields for the due date and related (contacts) field.

Remember – any dynamic fields used in here must have been set as columns in your advanced find at the start!

 N.B. If you want to set lookup fields in here, you need to use the following syntax:

 “Entity plural name(Entity Name)” – in my case this is contacts(Contact)


5. Testing

The top right of the flow creation screen gives you the options to check your flow for any errors before saving, and also to test this on some data in your environment, without having to navigate back into your environment every time. For a scheduled workflow, if you click ‘I’ll perform the trigger action’, then it will just run on all records when you click test, you don’t need to do anything in Dynamics. Flow will then show you the steps it has passed/failed on, and will show the inputs/outputs of each step it has run through so you can more easily troubleshoot any potential issues.


Now you’re good to go!

The ability to easily create date reminders for long term expiry dates is a great function which isn’t easy using standard workflows in Dynamics. It means we’re not using up any processing power by having workflows sitting on eternal wait conditions, and it’s easier to immediately tell if something has gone wrong – checking the status of your flow runs is simpler than checking on workflow errors.

This will allow the charity I’m working with the ability to not worry about missing an expiry date on their contacts’ Gift Aid declarations – they will just be able to review these as and when they’re needed through their usual task list, rather than having to have a separate view for contact expiry dates which requires an extra manual check.

Another area where I will be reusing this functionality (and where it will be useful for a lot of companies) is for GDPR agreements/declarations. When there’s a lot going on in a company it’s so easy to let expiry dates slip through the cracks, but if this happens with a GDPR consent declaration, it can be a real problem for a company to lose those contacts. This will allow people to easily keep up to date with all their contacts consent declarations.

If you have any questions for us or if this is something you would like integrating into your organisation please use our Contact Us form or call us directly on 0161 348 7360 for further information and how to get started

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