{"id":42,"date":"2021-11-24T15:43:42","date_gmt":"2021-11-24T15:43:42","guid":{"rendered":"https:\/\/blog.citrus-lime.com\/crmc\/?p=42"},"modified":"2021-11-24T15:43:42","modified_gmt":"2021-11-24T15:43:42","slug":"using-a-scheduled-power-automate-to-trigger-expiry-date-reminders","status":"publish","type":"post","link":"https:\/\/blog.citrus-lime.com\/crmc\/using-a-scheduled-power-automate-to-trigger-expiry-date-reminders\/","title":{"rendered":"Using a Scheduled Power Automate to Trigger Expiry Date Reminders"},"content":{"rendered":"\n<p>By Jessica Corbett<\/p>\n\n\n\n<p>At the moment we are working with a charity that collects 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.<br><br>Initially, 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<br>to be a bit of a ham-fisted way of solving the problem.\u00a0<\/p>\n\n\n\n<p>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<br>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.<\/p>\n\n\n\n<p>We wanted to find a better solution to this problem. Jess hadn\u2019t had much (successful) experience using flow previously, so I didn\u2019t 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\u2026<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Creating Flow: Set Schedule<\/h2>\n\n\n\n<p>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.<br>To create a new flow, we navigate to https:\/\/make.powerapps.com\/ and go to our solution or \u2018My Flows\u2019 tab on the left, then I\u2019m going to select new \u2018Scheduled &#8211; From blank\u2019.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/2_47C946B9.png\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/2_thumb_40AA0A41.png\" alt=\"2\" title=\"2\" \/><\/a><\/figure>\n\n\n\n<p>This takes us to the recurrence screen, to define the starting date of our flow, and the recurrence \u2013 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.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/3_398ACDC9.png\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/3_thumb_196FC10C.png\" alt=\"3\" title=\"3\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">2. List Records<\/h2>\n\n\n\n<p>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 \u2018List Records\u2019 action.<br>First you need to click \u2018New Step\u2019 under your recurrence step, and then find the connector \u2018Common Data Service (Current Environment)\u2019<br><strong>N.B. Confusingly, there is also one connector called \u2018Common Data Service\u2019. When they appear in the list, hover over to check you\u2019ve got the right one!<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/7_3C33897A.png\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/7_thumb_1C187CBD.png\" alt=\"7\" title=\"7\" \/><\/a><\/figure>\n\n\n\n<p>You should then find the \u2018List Records\u2019 action under this connector, and select the relevant entity (Contacts in my case).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. Filter Records<\/h2>\n\n\n\n<p>There are a few different ways to filter records using flow here. I\u2019m going to use the Fetch XML method for this.<\/p>\n\n\n\n<p>To do this, go to your Dynamics environment, create an advanced find with all the required criteria.<\/p>\n\n\n\n<p>\u00a0\u00a0<strong>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 fields to the column list in your advanced find! I know this from some frustrating experience\u2026<\/strong><\/p>\n\n\n\n<p>&nbsp; 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\u2019ll change it in the next step.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/5_670BED8C.png\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/5_thumb_09CFB5FB.png\" alt=\"5\" title=\"5\" \/><\/a><\/figure>\n\n\n\n<p>Once you\u2019ve completed your advanced find, click \u2018Download Fetch XML\u2019 and paste this directly into the Fetch Xml Query field on the \u2019List Contacts\u2019 step. (If you\u2019re using this, you can bypass all the fields between Entity name and this one.)<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/6_309DCC3B.png\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/6_thumb_576BE27B.png\" alt=\"6\" title=\"6\" \/><\/a><\/figure>\n\n\n\n<p>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 \u2018Add Dynamic Content\u2019 button in its place.<\/p>\n\n\n\n<p>E.g.&nbsp;<em>&lt;condition attribute=&#8221;crmcs_giftaidvaliduntil&#8221; operator=&#8221;on-or-after&#8221; value=&#8221;<strong>01\/07\/2020<\/strong>&#8221; \/&gt;<\/em><\/p>\n\n\n\n<p>Flow gives you some helpful suggested functions for each field type in the \u2018expressions\u2019 tab \u2013 I\u2019m 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.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/8_504CA603.png\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/8_thumb_30319946.png\" alt=\"8\" title=\"8\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">4. Add Task to Every Selected Record<\/h2>\n\n\n\n<p>To run a follow-up action on every listed record, you now need to add a new step to your flow and find the \u2018Apply to each\u2019 action.<\/p>\n\n\n\n<p>In the \u2018Select an output from previous step\u2019, you should add the \u2018value\u2019 field from the dynamic content section, then add a new step for \u2018Create a new record\u2019 \u2013 I\u2019m going to use the task entity.<\/p>\n\n\n\n<p>Here you can either set hard-coded or dynamic field values based on previous flow steps. I\u2019m going to use a hard coded subject and description field, and dynamic fields for the due date and related (contacts) field.<\/p>\n\n\n\n<p>Remember \u2013 any dynamic fields used in here must have been set as columns in your advanced find at the start!<\/p>\n\n\n\n<p>&nbsp;<strong>N.B. If you want to set lookup fields in here, you need to use the following syntax:<\/strong><\/p>\n\n\n\n<p><em>&nbsp;<strong>\u201cEntity plural name(Entity Name)\u201d \u2013 in my case this is contacts(Contact)<\/strong><\/em><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/9_10168C89.png\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/9_thumb_4FE0730E.png\" alt=\"9\" title=\"9\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">5. Testing<\/h2>\n\n\n\n<p>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 \u2018I\u2019ll perform the trigger action\u2019, then it will just run on all records when you click test, you don\u2019t 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.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/11_45B0D1DA.png\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/11_thumb_68749A48.png\" alt=\"11\" title=\"11\" \/><\/a><\/figure>\n\n\n\n<p><strong>Now you\u2019re good to go!<\/strong><\/p>\n\n\n\n<p>The ability to easily create date reminders for long-term expiry dates is a great function that isn\u2019t easy using standard workflows in Dynamics. It means we\u2019re not using up any processing power by having workflows sitting on eternal wait conditions, and it\u2019s easier to immediately tell if something has gone wrong \u2013 checking the status of your flow runs is simpler than checking on workflow errors.<\/p>\n\n\n\n<p>This will allow the charity I\u2019m working with the ability to not worry about missing an expiry date on their contacts\u2019 Gift Aid declarations \u2013 they will just be able to review these as and when they\u2019re needed through their usual task list, rather than having to have a separate view for contact expiry dates which requires an extra manual check.<\/p>\n\n\n\n<p>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\u2019s a lot going on in a company it\u2019s 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.<\/p>\n\n\n\n<p><strong>If you have any questions for us or if this is something you would like integrating into your organisation please use our&nbsp;<a href=\"https:\/\/www.crmcs.co.uk\/contact-us.aspx\">Contact Us<\/a>&nbsp;form or call us directly on 0161 348 7360 for further information and how to get started<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>At the moment we are working with a charity that collects 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.<\/p>\n","protected":false},"author":43,"featured_media":43,"comment_status":"open","ping_status":"open","sticky":true,"template":"","format":"standard","meta":{"_price":"","_stock":"","_tribe_ticket_header":"","_tribe_default_ticket_provider":"","_tribe_ticket_capacity":"0","_ticket_start_date":"","_ticket_end_date":"","_tribe_ticket_show_description":"","_tribe_ticket_show_not_going":false,"_tribe_ticket_use_global_stock":"","_tribe_ticket_global_stock_level":"","_global_stock_mode":"","_global_stock_cap":"","_tribe_rsvp_for_event":"","_tribe_ticket_going_count":"","_tribe_ticket_not_going_count":"","_tribe_tickets_list":"[]","_tribe_ticket_has_attendee_info_fields":false,"footnotes":""},"categories":[3],"tags":[],"class_list":{"0":"post-42","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-crm"},"featured_image_src":"https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2021\/11\/Untitled-design-41.png","author_info":{"display_name":"jadesmith","author_link":"https:\/\/blog.citrus-lime.com\/crmc\/author\/jadesmith\/"},"_links":{"self":[{"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/posts\/42","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/users\/43"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/comments?post=42"}],"version-history":[{"count":1,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/posts\/42\/revisions"}],"predecessor-version":[{"id":44,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/posts\/42\/revisions\/44"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/media\/43"}],"wp:attachment":[{"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/media?parent=42"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/categories?post=42"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/tags?post=42"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}