In this video we show you how Microsoft’s Power Platform automates and simplifies business processes, interacts more intelligently with data, builds conversational interfaces – all within SAP.
A common scenario that we consultants are asked to solution is the need to notify or create records in preparation of an event or task. In today’s blogpost, we’ll walk through a scenario in which we’ve been asked to create an Annual Review record one month before the Account’s Fiscal Year Start Date. Enjoy!
Typically, with these types of solutions we need to utilize an ETL tool, such as Scribe or the KingswaySoft Dynamics 365 Adapter for Microsoft Dynamics SSIS – or by leveraging a Wait condition in a workflow. However, we can also solve this with Microsoft Flow using a Scheduled Flow.
To prepare for the solution, we created a custom Annual Review entity with a look up to the Account, as well as a Review Date field. Next, we create a custom date field – named Fiscal Year Start Date – on the Account Record. For this field, we specifically set the Behavior to Date Only, as it will not store the time, which will be critical in the Flow design.
Once we have the CRM fields in place, we are able to leverage Flow. We will start by creating a Scheduled Flow that will run on the first of every month at 10 AM:
The first step of the Flow will utilize the Initialize Variable action, which will identify the date value we need for the next step in the Flow. In order to identify the proper date value for our example, we need to identify the first date of the month following when the flow is run. For example, if it runs on July 1, we expect the result to be August 1. We used the following code:
Let’s step through how the action is modifying current date to get the value we are looking for:
Note: This code will work on any date during the month, thereby giving us the ability to run manually if an issue arises during the normal schedule.
Using the Date variable from the first step, we identify the records within Dynamics that fit that criteria. In other words, it shows us any Accounts for which the Fiscal Year Start Date = August 1.
From here, we will add a Dynamics Create a New Record action that will automatically wrap the action in an Apply to Each function. In other words, it will run the Create a New Record action for all the records identified in the previous List records functionality. The Create a New Record action will create an Annual Review record, assigning the Owner of the record as the owner of the Account, the Due Date to the Fiscal Date variable, and Account to the Account identified in the List records action.
Note: We could have performed many different actions instead of creating the Annual Review record. For example, we could have done the following:
Using Flow in this capacity is a great way to perform time-based activities, without using an ETL tool, such as Scribe or KWS and SSIS – or by leveraging a Wait condition in a workflow.
Hopefully this helps you see the ease of automating processes with Microsoft Flow. Don't forget to subscribe to our blog for more Dynamics 365 and Flow tips.