This post will guide you to set up a flow to close any CRM activity automatically based on the due date by using power automate.
Scenario
An Appointment activity in the CRM to be closed automatically based on the due date by using power automate flow.
Create an Appointment activity and set the due date and after execution of the workflow, the Activity will close when the due date is passed. Follow the below process to achieve this scenario.
Open Power Automate and create a Scheduled cloud flow.
To know more about how to run flows on schedule visit this Microsoft site.
Enter flow name and set the start date and time as well as recurrence.
Click create, it will show the recurrence window.
Define the workflow recurrence interval and frequency and list all the records on which the workflow will execute.
Click + New step and search for List rows in the dialog box.
In the table name select Appointments. Enter column names.
These are the fields (columns) that will use in this workflow.
Statecode, scheduledend, activityid, new_currentdatetime, statuscode.
And the filter will apply to the active records so we can add the ‘statecode ne 1’ and ‘statuscode ne 1’. It means the workflow will only pick those records having status not equal to completed.
Click + New Step and search for the control ‘Apply to each’.
In the Apply to each control select ‘Value’ in the output section.
Add an Action and select condition.
Add a condition that will check if the End Time is less than Current Date Time.
If the condition is Yes then update record.
In Update a record action select Appointment entity and in the row ID select Appointment as we wanted to apply it for all the Appointments.
Set the status and status reason as completed.
Activate the workflow.
To test it, create an appointment under an Opportunity and set the start time and end time. The workflow will execute once it reaches the end time and it closes the Appointment.
The workflow executes successfully.
Thanks for going through this post. I hope you can understand now how to close CRM activity automatically by using power automate.
Read: How to customize the CRM using Power Apps?