Support Portal ContactGet in touch

Using a Scheduled Flow to Trigger Expiry Date Reminders

   Words by CRM Consultancy

   on 10/07/2020 10:23: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 2nd child 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 https://make.powerapps.com/ and go to our solution or ‘My Flows’ tab on the left, then I’m going to select new ‘Scheduled - From blank’.

2

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.

3

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!

7

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.

5

    

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.)

 

6

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.

8

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)

9

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.

11

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

  • "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
Manchester
M1 6EQ

London Office
CRM Consultancy London
Grosvenor Avenue
London

Content © CRM Consultancy.