One requirement that is repeatedly being asked for by customers in Power Platform projects is the ability to schedule a workflow on a collection of record.

For example: I want to run a daily (classic) workflow on every active contact at midnight. Unfortunately, there is no out-of-the-box way of implementing this requirement inside Microsoft Power Platform.

It turns out that it can be easily implemented by combining FLOW and a bit of tweaking.

The trick is to encapsulate your existing workflow into a single Action.

The nice thing about Actions in Power Platform is that they are exposed by the web api and every Action is reachable with an HTTP post request

//{TENANT}.{REGION}.dynamics.com/api/data/v9.1/{ENTITYLOGICALNAME}({GUID})/Microsoft.Dynamics.Crm.{ACTIONNAME}

Here is the setup:

 

– IN CLASSIC WORLFLOW –

Have your existing workflow set to be available to run as a ‘child process’

 

Create a new process of type ‘Action’ with the same base Entity as the workflow to schedule

In the action steps: add a ‘Start a Child Workflow’ step and select the workflow from step 1.

 

 

 

 – IN FLOW – 

For the FLOW part, it is quite easy to configure. Here is the high-level view of the resulting FLOW:

 

Set the pagination to ‘ON’ on the List Records task

Don’t forget to set the pagination to ‘ON’ on the List Records task, otherwise your list will be limited to the first 512 records.

Also, be aware that there is a limitation of 100 000 loops in the ‘Apply to each’ task.

 

Use HTTP with Azure AD connector

For the HTTP call to the Power Platform WebApi, since we need to obtain a token to make the call securely, we cannot easily use a classic HTTP call.

Instead we make use of the HTTP with Azure AD connector.

Once this connector is configured with the right credential, it will be able to perform secured calls to the Power Platform API.

 

Just put your Power Platform instance base URL and click ‘Sign In’

You will be prompted to enter valid credentials.

Note that this user must have the right security role on the Power Platform side.

 

In the URL of the request, enter the Action URL with the current record ID (GUID) as a parameter

 

Improve your performance with a few adjustments

To improve performance, there are some settings that need to be adjusted.

First, set the parallelism of the Apply to each task.

Set the concurrency Control to ‘ON’ and set the parallelism to 50.



Also, since we will perform a lot of calls to the Platform Api we might receive some 429 errors. Saying that, you need to retry your call in ‘X seconds’.

 

To prevent the 429 errors, simply adjust the Retry Policy of HTTP call.

For example, change the Retry policy to ‘Fixed Interval’, for a max retry count of 25 and 10 seconds between each retries.

 

Successful execution of the FLOW will look like this:

 

Performances

Here are the benchmarks I came up with during my tests.

So, we get an execution throughput of about 100 requests/min.

 

Conclusion

This approach shows that it is possible to schedule Power Platform (classic) workflows using FLOW. It provides a robust and inexpensive cloud-based solution for scheduling workflows.

 

Want to know more about best practices to optimize your CRM solution? Ask your questions to our experts, who will be able to offer you personalized advice!

To stay on top of the latest news, follow us on LinkedIn or Twitter!


This article was made possible by tapping into the expertise of our CRM developer David Rivard.