Workflows

Branch a Workflow Based on a Condition

Workflows often need to take different paths based on field values, user choices, or business logic. This guide shows you how to build conditional branches using ServiceNow's workflow activities and transition conditions.

Why linear workflows break down

Most workflows start simple — approve a request, update a record, send a notification. But real business processes have decision points. Maybe high-value requests need additional approval, or different request types need different fulfillment teams. Without conditional branching, you end up building separate workflows for each scenario, duplicating logic and creating maintenance headaches for workflow designers and platform admins who inherit these processes.

How workflow conditions work

ServiceNow gives you three ways to branch workflows: If activities for simple true/false conditions, Switch activities when you have multiple discrete paths, and transition conditions that let any activity branch without explicit conditional blocks. All condition evaluation happens server-side using the workflow context — you can reference current record fields, workflow scratchpad variables, or run custom scripts. The key insight is choosing the right approach: If/Else for binary decisions, Switch for multiple known outcomes, and transition conditions when you want clean workflow diagrams without cluttering them with decision diamonds.

Building robust conditional logic

Basic conditional workflows work fine for simple scenarios, but production-quality implementations need error handling, logging, and maintainable condition logic. Extract complex conditions into Script Includes so multiple workflows can reuse them. Add logging activities on each branch so you can trace execution paths when troubleshooting. Design your conditions to handle edge cases — null values, unexpected field states, or missing reference data that breaks your branching logic.

Before you start

  • wf_editor or admin role
  • Existing workflow to modify or workflow category to create new ones
Sourdough
Chrome Extension

Sourdough: ServiceNow Monitoring and Analytics

A Chrome extension for ServiceNow Admins and Developers with essential tools, analytics, graphs and monitoring features.

Instance HealthGraphs & ChartsAPI HealthDeveloper ToolsQuick SearchInstance Switcher
Add to Chrome

Free to install. Pro $5/month after a 14-day no-card trial.
Pro requires the ServiceNow admin role. Upgrade inside the extension.

Overview
Tasks
CMDB
API
Metrics
Monitor
Internals
Instance:sourdoughdev·Version:Yokohama
Instance StateONLINE
System StatusFully Operational
Session Timeout90 minutes
Logged-In Sessions2 (20 active)
Build Nameyokohama-12-18-2024_p1
IP Address10.159.128.43
Instance HealthHealth Score: 90%
🔥 5dSourdough (Chrome Plugin)Dark Mode

Step by step

1

Open your workflow for editing

Navigate to Workflow > Workflow Editor and select your workflow. If you're starting fresh, create a new workflow and add a Begin activity. The workflow canvas needs to be in edit mode — you'll see the activity palette on the left side of the screen.

TIP

Check out an existing workflow to see conditional branching in action — the 'Service Catalog' category has good examples.

2

Add conditional activity from palette

Drag either an If or Switch activity from the Core tab onto your canvas. Use If for simple true/false decisions like checking if a dollar amount exceeds a threshold. Use Switch when you have multiple discrete paths based on a field value — like routing different request types to different teams. Position the activity where you need the decision point in your workflow.

TIP

Switch activities perform better than chained If/Else blocks when you have more than three possible outcomes.

3

Configure the condition logic

Double-click your conditional activity to open its properties. For If activities, set your condition in the Condition field using workflow syntax like 'current.amount > 1000' or 'current.state == 3'. For Switch activities, set the Condition field to the variable you're switching on (like 'current.category'), then define your Case values in the Cases tab — each case gets its own execution path.

TIP

Use current.field_name.getDisplayValue() for choice fields to make conditions more readable than comparing to numeric choice values.

4

Build activities for each branch

Add the activities that should execute on each branch. For If activities, connect activities to the 'yes' and 'no' outputs. For Switch activities, each case value gets its own output connector — drag activities for each case and connect them to the appropriate output. Don't forget to handle the 'default' path for Switch activities when none of your cases match.

TIP

Add Log Message activities at the start of each branch during development — makes debugging condition logic much easier.

5

Set up transition conditions

Right-click any activity and select 'Add transition' to create multiple outbound connections with different conditions. In the transition properties, set the Condition field to determine when that path executes. This approach keeps your workflow diagram cleaner than explicit If blocks — especially useful when an approval might go to different groups based on request attributes.

TIP

Order matters with transition conditions — ServiceNow evaluates them top to bottom and takes the first match.

6

Test condition evaluation

Save and publish your workflow, then test it with records that trigger different branches. Use the workflow context viewer (right-click the workflow instance > Show Details) to see which conditions evaluated true and which path the workflow took. Create test records with different field values to verify all your branches work correctly.

TIP

Test edge cases like null values and empty choice fields — they often break conditional logic in unexpected ways.

Best practices

  • Extract complex condition logic into Script Includes rather than embedding long scripts in workflow activities — makes the logic testable and reusable across workflows.

  • Always handle the default case in Switch activities and the 'no' branch in If activities, even if it's just a log message — unhandled branches cause workflows to hang.

  • Use transition conditions instead of If activities when you're just routing to different groups or setting different values — keeps the workflow diagram cleaner and easier to follow.

  • Avoid querying the database inside condition scripts — if you need related record data, query it once in an earlier activity and store results in the scratchpad.

  • Log the condition values and branch taken at decision points — when workflows behave unexpectedly months later, these logs are essential for debugging.

Test Your Knowledge

Quick 3-question quiz — see how your ServiceNow skills stack up.

Question 1 of 3Performance

A list view on a table with millions of records is slow. Best fix?

Select an answer to continue