In this webinar, our experts showcase a variety of demo use cases of how different components of the...
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.
Set this workflow as "Child Process" and as "on-demand" as well:
When complete, it will look like the sample below:
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!
Thanks a lot for your useful article.
I can do this by only one workflow that recall itself.
I tried this approch, but workflow is failing for 16th recusrion, any idea?
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!
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!
Hi, The max depth is 12 and the max recursion is 7 per hour. On the 8th within 1 hr it will detect an infinite loop and stop. If you are on premises, this setting is adjustable: https://powerobjects.com/blog/2015/09/25/increasing-the-maximum-number-of-nested-child-workflows/
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.
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?
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?
It appears that this is only running on the initial record that was selected to execute the workflows.....
Hi Kris, did you get a resolution for the workflow to run on all records after manually running it. Thanks a mill
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?
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
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
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
Hi I have exactly the same problem did you find any solution to this ?
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