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

Share this Article

Search Articles

Filter Articles

CRM Tech DocMan

Recent Articles

Dynamics for Sales: Use Word Templates to Export directly to PDF Newly Generated Documents in Dynamics or Power Apps do not save into SharePoint Synchronising Dynamics / Power Apps Security with SharePoint Adding the DocDrive Bot to each new Microsoft Team Microsoft Team for each Key Account using Conditional Rules in DocDrive365 Styling Azure B2C for Power Apps Portals Azure B2C–the Subscription is not Registered Azure B2C and Power Apps Portals – User Flow for Signup and Signin Creating a New Azure AD B2C Tenant New Application Registration in Azure B2C for our Power Apps Portal Using Power Automate to Integrate Microsoft Forms with Dynamics 365 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
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
 
Close

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