Conditions allow you to add business logic to manage the actions of your workflow rule. You have the ability to create simple or complex logical statements that control when actions should be taken. Typical scenarios might include sending an e-mail message a month before a service contract expires, creating different sets of activities based on potential revenue of an opportunity, or updating a sales stage when all activities are completed.
After you name the workflow rule and select a workflow event, Microsoft CRM opens the Select Behavior page, on which you can edit the workflow. You can insert a condition by clicking Insert Condition in the Common Tasks section, as shown in Figure 8-6.
Figure 8-6: Inserting a condition
Microsoft CRM automatically determines which conditions you can insert into a workflow rule, depending on which part of the rule you select in the statement box. For instance, you can use the Else If option (shown in Figure 8-7) only within an existing Check condition.
Figure 8-7: Subconditions available based on the context of the statement box
Let's discuss the options available when adding conditions to your workflow rules. Conditions can be broken into the following high-level categories, in which each has possible subconditions available:
Check conditions
Wait for conditions
Wait for timer
Check conditions provides you with a logical if-then-else arrangement for use in your workflow rules: If the defined conditions are met, then perform the actions listed. Additionally, you can nest conditions within other conditions to create more sophisticated evaluation criteria. Figure 8-8 shows a rule that first checks if the Account is a standard customer AND has an annual revenue greater than $10,000,000. If both conditions are true, then it updates the Account's category to a preferred customer.
Figure 8-8: Grouped conditions
Note | Nested conditions are always evaluated with an AND operator. The OR operator is not available for grouped conditions. You would have to create separate conditions to accomplish an OR. |
After you insert a check condition and select it, workflow offers you the following subconditions:
Check entity condition Evaluates the value of a specific attribute (field) of the entity. The operators available are based on the data type of the field chosen.
Check activities Returns a value of true if any activities exist for the entity. You can only include activities created by a workflow rule. This condition is not applicable to rules created for Activity entities.
Else if Continues the conditional logic only if the first condition returns false.
Figure 8-9 shows the page for adding a new check entity condition statement.
Figure 8-9: Adding a check entity condition
Wait for conditions pauses a workflow rule until the conditions specified within the wait statement are completed. Figure 8-10 shows a workflow rule for the Account entity trigged by the Create event. It waits until the Account entity's category equals Preferred Customer and then sends a welcome e-mail message to the account.
Figure 8-10: Wait for condition
Two subconditions exist for the Wait for conditions statement. Both prevent the continuation of the rule until their conditions are met:
Wait entity condition Evaluates the value of a specified field before continuing
Wait activity condition Checks to determine whether an activity from a previous step in the rule reaches a specified value of Completed, Cancelled, or Either before continuing
Caution | Wait activity condition can only check for activities created by workflow. |
Similar to Wait for conditions, Wait for timer allows you to suspend your rule until a chosen amount of time elapses. A few scenarios that benefit from this condition include:
Sending reminder e-mail messages before the expiration of a contract, an opportunity closing, or the start date of an appointment.
Changing ownership of a Lead or Case record one day after creation if someone has not addressed the record.
Checking the status or the activities of an opportunity one month after initial creation.
The following three settings determine the starting point for your timer:
From now on Waits for the amount of time specified from when the condition step is executed.
After Starts the timer after a selected value from the referenced entity.
Before Begins the timer before a selected value from the referenced entity.
Figure 8-11 shows how to configure a timer condition to wait one month after the actual close date of an opportunity.
Figure 8-11: Wait for timer condition
Note | You can set up your rule to wait from 1 minute to 24 months! |