Comment unsuccessful. Please correct the errors below.

Recurrent workflow in CRM 3

From time to time a question comes up in the newsgroups how to create a workflow rule that follows some recurrent pattern. For example, just yesterday surfbluedog (not her real name) asked:

The rule needs to wait for a 6 week period from the oncreate date. This sounds pretty simple. Well during this 6 week period, 2 messages (activities) need to be sent out...

... the messages need to be sent out twice daily throughout the 6 week period.

As a word is worth 1/1000th of a picture, I've decided to create an illustrated guide on how to complete the challenge. In this example we are going to create a rule for account entity that, after an account is created, will send a message on a daily basis until the deadline.

First of all, workflow in Microsoft CRM 3 does not have a concept of looping flow control statements in any shape or form. To create a recurrent pattern we need to use a manual rule that calls itself as the last step of execution (with some conditions, of course, to stop it from looping indefinitely). [more]

Manual rule

  1. Start Workflow Manager and, no, you don't have to do it on the server.
  2. Create new manual rule for account entity called, say, Send a message:
    New manual rule
  3. First of all, we need to save 6 weeks deadline somewhere to be able to use it later in a condition. Arithmetic is not the strongest feature of the CRM workflow but a call to the date/time workflow assembly included with CRM is to the rescue:
    Workflow assembly call
  4. Name action Saved Deadline
  5. Double-click Date and time and specify Created On  as a source value:
    Source value for adding date/time
  6. Double-click Days and specify static value of 42 (love it!). Sorry, no weeks allowed:
    42 days == 6 weeks
  7. Your assembly call should now look like this:
    Assembly call in action
  8. Now we can check if deadline has passed and stop the workflow if it did. Click Insert Condition->Check condition. In if part click Insert Condition->Check entity condition.
  9. Select Saved Deadline as an entity (I knew it'll come handy!). Select <= condition and Execution Time static value as a right-hand-side:
    Check the deadline
  10. In then section insert Stop action. Select Complete when asked how do you want to stop your workflow.
  11. Since the rule is going to be called in a loop, we now need to wait 1 day until sending the next message. Select end if line, click Insert Condition->Wait for timer. Specify 1 day from now on:
    Wait for 1 day
  12. Now, the meaty part, sending the actual message. Insert Action->Send e-mail. Fill in details as required by your process, we are simply going to remind user that 6 weeks are not up yet:
    Send annoying e-mail
  13. Save the rule. Yes, we want the rule to call itself but until it's saved, it's not available to be called.
  14. Open the rule, select the last line, click Insert Action->Run subprocess. Select Send a message subprocess.
  15. Your manual rule should look like this:
    Completed manual rule

Jump-starting the rule

Now we are ready to automate the process to start sending spam notifications after an account is created.

  1. Create another workflow rule, this time event is Create:
    New Create rule
  2. This rule is a very simple one-liner: Insert Action->Run subprocess. Select Send a message subprocess. Your rule should now look like this:
    Completed jump-start rule

We are done! Now simply activate both rules by selecting them (you can use Shift and Ctrl keys to select more than one rule) and click Activate toolbar button. As soon as new account record is created, the manual rule is going to kick in and annoy record owner with daily e-mails for 6 weeks. Which is exactly what we wanted.

Posted by: George Doubinski
Last revised: 05 Dec, 2012 05:25 PM


Your Comments

Comment unsuccessful. Please correct the errors below.
Used for your gravatar. Not required. Will not be public.
Posting code? Indent it by four spaces to make it look nice. Learn more about Markdown.