Looking for PowerObjects? Don’t worry, you’re in the right place! We’ve been part of HCL for several years, and we’ve now taken the final step in our acquisition journey: moving our website to the HCL domain. Nothing else is changing – we are still fanatically focused on Microsoft Business Applications!

PowerObjects Blog 

for Microsoft Business Applications


Create Recursive or Scheduled Workflows in CRM

Post Author: Joe D365 |

Workflows are a valuable tool within Microsoft Dynamics CRM. So what if you want to schedule workflows at a certain time, or execute a workflow every night, week, or month? This blog will show you how to create a recursive workflow to be executed for a certain time, and how to create scheduled workflows in CRM.

In this example, we will create workflows to be executed every night, which will check if the account's primary contact is empty. If it is empty, the workflow will find its primary contact and populate the primary contact field.

  1. Create the 1st new workflow with Contact as the primary Entity.

    Set this workflow as "Child Process" and as "on-demand" as well:

    scheduled workflows in CRM

  2. Add a wait condition to start every day or every 24 hours.

  3. Add check conditions and actions. One of the actions is called a child workflow, the identical second workflow, right before stop itself.

    When complete, it will look like the sample below:

  4. Create the second workflow similarly.
  5. The workflow will need to be to be triggered manually the first time.

Once you have triggered one of the workflows, it will automatically execute and trigger the other workflow right before it stops. Therefore, only one of the workflows will be in  process and handle the same job recursively.

If you want the workflow to start at 3:00 a.m. and you don't want to stay up in the middle of the night to manually trigger it, you can create a third workflow, which will have a similar timeout condition set as step 2. The third workflow will trigger the first workflow instead of having to be manually triggered by you.

Similarly, if you just want to create a scheduled workflow instead of a recursive workflow, you can simply create the first workflow with a timeout condition set as step 2; then, wait for certain time to trigger the second workflow.

In summary, you can set up two identical-child-type workflows to handle recursive jobs; add an additional timeout workflow to handle any scheduled jobs.

If this was helpful, you may also want to review the post on time and condition based workflows.

Happy CRM'ing!

Joe CRM
By Joe D365
Joe D365 is a Microsoft Dynamics 365 superhero who runs on pure Dynamics adrenaline. As the face of PowerObjects, Joe D365’s mission is to reveal innovative ways to use Dynamics 365 and bring the application to more businesses and organizations around the world.

16 comments on “Create Recursive or Scheduled Workflows in CRM”

  1. Thanks a lot for your useful article.
    I can do this by only one workflow that recall itself.

  2. Thanks so much - I've been trying to figure out how to do this and pretty much EVERY other website says to create entity records which can be deleted through a scheduled bulk delete operation!

  3. This doesn't work. A single recursive workflow that triggers itself as a child workflow would only function for 7 full iterations but fail on the 8th.
    A pair of 2 workflows alternatively triggering each other (like you suggested) doesn't solve the problem, as they too stop at the 8th iteration.
    After testing with 10 chained workflows, I found out that even then the 8th was failing.
    The Update method doesn't seem to work any better. Even when I tested with 10 workflows, triggered by the update of 10 different fields (one for each), that updated the field of the next workflow, thinking that I got him this time, the execution still ended at the 8th iteration.
    I tried timeout-ing the workflows triggers (like in your example), and not timeout-ing them, tried adding the Stop Workflow at the end, and not adding it, only to get the same results: nothing gets past the 8th iteration.
    The workflow mechanism seems to be extremely aware of infinite loops, regardless of their form, it's quite annoying!

      1. You're right! I was only delaying the workflows 1 to 5 minutes in the previous tests. When I increased the delay to 1 hour, it successfully ran 25 iterations (in 25 hours) and I had to stop it manually. I used a single workflow though.

      2. What does it mean that the max depth is 12? i understand that if my workflow's schedule spans across 24 hours, it won't hit the 7 iterations per hour threshold.. however, what is this this depth of 12?

      3. What does it mean that the max depth is 12? i understand that if my workflow's schedule spans across 24 hours, it won't hit the 7 iterations per hour threshold.. however, what is this this depth of 12?

  4. It appears that this is only running on the initial record that was selected to execute the workflows.....

    1. Hi Kris, did you get a resolution for the workflow to run on all records after manually running it. Thanks a mill

  5. Hi

    Thank for the solution of my problem but I am facing another issue.

    My workflow start at 8:00 AM and I call Custom workflow assembly which get the bulk data and post in crm and this activity takes 15 minutes. After 1 day wait , child workflow start at 8:15 AM and the increment of time continuously goes in every day.

    is there any condition that wait 1 Day after the workflow creation?

    1. You may perhaps initiate the workflow first and then start with your processing of your tasks.. this way, your workflow has already initiated the second day's workflow @ 8:00 PM and after that your task for today is executing for as long as it wants to

    2. You may perhaps initiate the workflow first and then start with your processing of your tasks.. this way, your workflow has already initiated the second day's workflow @ 8:00 PM and after that your task for today is executing for as long as it wants to

    3. You may perhaps initiate the workflow first and then start with your processing of your tasks.. this way, your workflow has already initiated the second day's workflow @ 8:00 PM and after that your task for today is executing for as long as it wants to

  6. Thanks for this solution, a question though if you run on-Demand for the first time you have to choose some records before you can run the workflow manually. Will the process run for all records and not just the set regarding ones? thanks a mill

PowerObjects Recommends