How to create a repeating schedule workflow rule

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

image

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.

image

3. Select the Anniversary attribute to trigger the record attribute change event

image

4. Add a Wait condition to wait until the Contact’s next Anniversary date

image

5. Add a ‘Send E-mail’ step, set the required email template (assuming you have one) and email details

image

6. Add an ‘Update Record’ step and set it to update the Contact’s anniversary date to next year Anniversary date

image

7. By the end, your work flow rule should look something like this:

image

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.

 

Advertisements

5 thoughts on “How to create a repeating schedule workflow rule

  1. sebastian May 3, 2011 / 8:25 pm

    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?

    Like

  2. Hosk May 3, 2011 / 10:44 pm

    good question. I wonder how the wait code works, does it check it the date every day to see if it’s the day?

    Like

  3. Casper Schau May 17, 2011 / 11:39 am

    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

    Like

  4. Eric July 20, 2011 / 6:40 pm

    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

    Like

  5. Usman March 20, 2012 / 9:57 am

    Thanks for explaining repeating schedule workflow rule

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.