Recently we received a business requirement where client wants to send Birthday Emails to the CRM contacts. We tried this using Microsoft Flow. In this blog we will discuss this.
First we need to create a Recurrence trigger so that this functionality will run every day.
To create recurrence trigger in Flow please follow below steps:
1. Click on “Create from Blank” button as shown in below screenshot.
2. After clicking on “Create from Blank” below window will appear and then search for the Recurrence trigger once clicked on “Search hundreds of connectors and triggers”
3. Click on below trigger shown in the screenshot
4. Set Interval as ‘1’ and Frequency as ‘Day’ as shown below.
This is how the recurrence trigger will get created.
When the recurrence trigger gets created then you need to create Action to list all the Contact entity record from your CRM, you can follow below steps to create action.
1. Click on ‘New Step’ button and then ‘Add an action’ button as shown below
2. Then select Dynamics 365 and List records as shown below
3. Select the ‘Organization name’ from option set, Entity Name should be ‘Contact’ and Filter Query to filter the records from CRM (i.e. get the list of Active records only)
When the listing of all contacts from CRM is completed then we need to click on ‘Add an apply to each’ option, so that we can run the flow on every record. Follow below step to add and apply to each option in Microsoft flow.
After the above step add a condition to compare ‘Birthday’ date to ‘Todays’ date as shown below.
Use below fetch expressions in the condition attribute.
1. To get the Value from CRM Birthday field use below expression, this expression will format date time and convert date to MM/dd format.
2. To handle the Null Condition i.e. if the Birthdate field doesn’t contain any values then you need to modify the above formula as shown below
if(equals(items(‘Apply_to_each_2’)?[‘Birthdate’], null), ”,
3. Use “is equal to” operator for comparing the Date fields.
4. Then use today’s date to compare the CRM Birthday field Date
If the above condition matches then as shown in above screenshot you can Send Email to the Contact for which the condition is successful, otherwise it will ignore the process.
To send the email ‘To’ field is mandatory by using the below expression you will get the value of the field.
You can provide Subject and Body of the email as per your specifications.
Yes condition will look like below screenshot
Using the steps above the user can automatically send email greetings on birthdays using Microsoft Flow.