I saw this blog post today by Yaniv Arditi, what I really liked about the solution was how simple and elegant it was. It also used the functionaility in CRM, it reminds you about how useful and powerful workflows are.
I have put this on my blog so I can find this again because I’m sure that sometime in the future I will have to do something like this, in the past this has usually been done programming with .NET code, this solution offers an alternative to that. It could be used by consultants who haven’t got access to a developer.
How to create a repeating schedule workflow rule
I am often asked by my clients if Microsoft Dynamics CRM 4.0 can automatically schedule and perform a repeating task, such as sending an email notification to a Contact every year or adding a Note to a Contact record every day.
One trivial solution to this problem is developing a custom module that will be repeatedly launched by Windows Scheduled Tasks feature or Windows Service and perform the required task.
Another solution, one that does not require writing code, can be implemented using the Work Flow engine.
Let’s take, for example, a scenario in which we would like to automatically send ‘Happy Anniversary’ email greeting to our Contacts on their Anniversary day.
The following 8 steps describe how to set up the required work flow rule:
1. Create a new blank work flow rule for the Contact entity
2. Set the rule to be triggered by both the record Creation and Attribute change events. Set the scope to user, at least until you have tested the rule.
3. Select the Anniversary attribute to trigger the record attribute change event
4. Add a Wait condition to wait until the Contact’s next Anniversary date
5. Add a ‘Send E-mail’ step, set the required email template (assuming you have one) and email details
6. Add an ‘Update Record’ step and set it to update the Contact’s anniversary date to next year Anniversary date
7. By the end, your work flow rule should look something like this:
8. Publish the work flow rule
9. Test the rule by creating a new pseudo Contact with a future date (e.g. tomorrow) as anniversary date and your email address. If all went well, you should be able to see a new rule instance waiting in the Contact’s workflows grid.
Past the target date, verify that the workflow rule has advanced and that you have received the greeting email. Also make sure the Contact’s Anniversary date has been updated to next year anniversary date.
What happens if someone creates the contact and then edits it? Will there be two workflows running, waiting for the anniversary date? Will two emails be sent?
good question. I wonder how the wait code works, does it check it the date every day to see if it’s the day?
You gonna have a problem with recurring workflows as well. This workflow can run for 7 times. The 8. time the worflow begins, it well fail with a recurring error message
sebastian – as long as the user is not updating the anniversary date on the contact record it should not create another workflow based on the edit.
you may have to add some conditional logic to keep it from generating several workflows when making an edit.
Thanks for the directions Hosk
Thanks for explaining repeating schedule workflow rule