A recurring workflow is, basically, a workflow that starts itself. There have been rumors that recurring workflows in Dynamics CRM can be implemented using child workflow (for example, by adding “wait” step and, then, starting a child workflow of the same type). However, I’ve never been able to really make it work since Dynamics turned out to be very diligent when it comes to terminating this sort of workflows. It usually allows the workflow to run for a few times, and, then, just when you think you’ve finally tricked it into allowing the workflow to go on indefinitely, you see that message that a workflow has been terminated.
Yet we do need such workflows – the most obvious example of why we do is “age” calculations. After all, people do want to send out an email to the customers/contacts having a birthday today.
However, at some point, I actually gave up on the idea to use recurring workflows since I could never make them work.
There are workarounds, of cause. One can write a console application/windows service/etc to do something in CRM periodically. Well, it works for some of us, and it does not work for others. After all, you have to deploy and schedule that application somewhere, and that introduces other issues.
I’ve been dwelling on it for almost half a year, and, it seems, I’ve finally got my “a-ha” moment just a few days ago. There are recurring jobs in CRM, and those jobs are perfectly “legal” from CRM standpoint. One can always create a bulk delete job and schedule that job to run daily. Well, no, not more frequently. You’ll have to schedule more than one job for that.
However, the point is, a recurring workflow can, then, be implemented like this:
- Create a new entity
- Schedule bulk delete job that deletes all records of that entity type
- Add a workflow for that entity which starts whenever a record is deleted
- Do whatever you need in that workflow (if you need a custom workflow activity, or a plugin.. go ahead)
- At the end of the workflow, create new record of the same entity type
Here you go – you’ve got a recurring workflow, and CRM has nothing to complain about.