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]
- Start Workflow Manager and, no, you don't have to do it on the server.
- Create new manual rule for account entity called, say, Send a message:
- 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:
- Name action Saved Deadline
- Double-click Date and time and specify Created On as a source value:
- Double-click Days and specify static value of 42 (love it!). Sorry, no weeks allowed:
- Your assembly call should now look like this:
- 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.
- Select Saved Deadline as an entity (I knew it'll come handy!). Select <= condition and Execution Time static value as a right-hand-side:
- In then section insert Stop action. Select Complete when asked how do you want to stop your workflow.
- 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:
- 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:
- Save the rule. Yes, we want the rule to call itself but until it's saved, it's not available to be called.
- Open the rule, select the last line, click Insert Action->Run subprocess. Select Send a message subprocess.
- Your manual rule should look like this:
Jump-starting the rule
Now we are ready to automate the process to start sending
spam notifications after an account is created.
- Create another workflow rule, this time event is Create:
- This rule is a very simple one-liner: Insert Action->Run subprocess. Select Send a message subprocess. Your rule should now look like this:
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.
Last revised: 05 Dec, 2012 05:25 PM