Tips for Using Workflow Condition Activities

Six years ago, Suzanne Smith from ServiceNow gave some tips for using workflow conditions activities. Suzanne wrote that some of the most prevalent condition activities were: If, Switch, Wait for condition, and Wait for WF event. Are these tips still relevant to this day?

ServiceNow workflows automate multi-step processes consisting of multiple activities linked with transitions. For example, you can create workflows for emergency change requests, service catalog requests, and knowledge base article approvals. Depending on your instance configuration, there are more than 23 activities to choose from when designing a workflow.
Some of the most popular and widely used activities are the four condition activities:
Wait for condition
Wait for WF event

Here is a description and tips for each of the condition activities.
“If” Condition Activity
Add the If activity to check a condition or script and determine if a Yes or No transition should occur.
For example, in the Employee Change HR workflow below, an If activity is added at the beginning to check if approval is required. If it is, the next activity sends an approval request to a group. If approval is not required, the next activity runs a script that updates the employee’s profile.

If the Condition and the Advanced script are both specified, then both must evaluate successfully for the Yes
transition to occur.
For some advanced tricks with the If activity, see Steve Bell’s (sabell2012) post titled
MIni-Lab: Workflows – Playing With the If Activity. Steve generously shares his knowledge and walks you through the creation of a workflow containing an interesting If activity.

“Switch” Condition Activity
Add the Switch activity to check if the passed field or variable value is equal to one of several case values.
For example, in the Contract Approval workflow below, there are two switch activities. Each of the switch activities asks the question, “What are we processing?” Based on the answer, None, Renewal, or Expired, the workflow continues and a set values or run script activity changes the state.

Customers sometimes have questions about whether to use an If activity or a Switch Activity. Use an If activity when the answer to the question is Yes or No and you are checking a single condition. Very simple. If there are different or more options than just Yes or No and you are checking multiple conditions at the same time, a Switch activity gives you more control.

“Wait for” Condition Activity
Add the Wait for condition activity to have the workflow pause indefinitely until the current record matches a specified condition. When the current record is updated, the workflow evaluates the Wait for condition activity.
For example, in the Employee Offboarding workflow below (only part of the workflow is shown), there are two wait for condition activities. One of the activities always causes the workflow to stop until the employee’s end date is reached. Another wait for condition activity always checks if all sub-tasks are inactive before moving on to the next activity.

There is an important difference between the Wait for condition activity and the Timer activity. If you need the workflow to pause for a specific, timed duration, use the Timer activity instead of the Wait for condition activity. The Timer activity gives you greater control over how long the workflow pauses and what causes it to start again after pausing.
The Wait for condition activity can be handy if you have multiple tasks that you want completed before the workflow ends. You can configure the Wait for condition so the workflow pauses until ALL tasks are complete.

“Wait for WF event” Condition Activity
Add the Wait for WF Event activity to have the workflow pause until a specified event is fi red.
For example, in the
Item Designer Fulfillment
workflow below, there is one Wait for WF Event activity following an If activity. The workflow waits for the sc_ic_req_task_complete event and then runs a script in the next activity.

For an excellent explanation of the Wait for WF Event activity and several detailed examples, see Russ Sarbora’s blog post
Waiting for [the workflow event named] Godot. Russ is an engineer on the Workflow team at ServiceNow and knows his stuff when it comes to activities!
Additional information:
ravish asked for help choosing between the If and Switch activities. Several people jumped in with good information including
deepak.ingale, sunilsafare, and

Rudi_Cro had an interesting dilemma with multiple tasks in a workflow. With help from the community and the product documentation, the solution turned out to be a Wait for condition activity.
For general information, see Using Workflow Activities in the product documentation.

Leave a Comment

Your email address will not be published. Required fields are marked *