Skip to main content

How Do I Use JSON Logic for Advanced Workflow Routing Rules?

Reference guide for using JSON logic in workflow routing rules.

Written by Lauren Baird
Updated over a week ago

This reference guide supports advanced Workflow Managers configuring route rules in the Workflow Editor (Rule Configuration).

Use JSON logic when the visual Rule Builder cannot support the required complexity. Question labels are case-sensitive and must match exactly, and complex rules should always be tested in a Demonstration (UAT) site before deployment.

If you are new to routing, start with Configuring Rule-Based Routes.


Answer

JSON logic allows you to build advanced routing conditions using structured operators. It is most useful when evaluating multiple conditions, checklist or multi-select responses, or nested logic scenarios that exceed the capabilities of the visual Rule Builder.


When to Use JSON Logic for Complex Route Rules

Use JSON logic when:

  • Multiple conditions must be evaluated together

  • Checklist or multi-select responses drive routing

  • Visual Rule Builder options are insufficient

Avoid JSON logic when:

  • A simple Match / Any / All rule will work

  • The logic becomes hard to explain or maintain


Steps

  1. Open the workflow in the Workflow Editor.

  2. Navigate to Rule Configuration for the applicable route.

  3. Select the option to enter or edit the rule using JSON logic.

  4. Structure the rule using the standard JSON format:

    { "operator": [ value1, value2 ] }
  5. Reference user responses using the exact question label:

    { "var": "Question Text" }
  6. Apply the appropriate operator (examples below).

  7. Save the rule configuration.

  8. Test routing behavior in a Demonstration (UAT) site before publishing.


JSON Logic Basics

Each rule follows this general structure:

{ "operator": [ value1, value2 ] }

Referencing User Responses

To reference a user’s answer, use the exact question label:

{ "var": "Question Text" }

⚠️ Question labels are case-sensitive and must match exactly.


Common Operators

Equals

{ "==": [ { "var": "response" }, "Yes" ] }

Not Equal

{ "!=": [ { "var": "response" }, "No" ] }

NOT (Negation)

{ "!": { "var": "response" } }

IN (Used for Checklists / Multi-Select)

{ "in": [ "Eye Protection", { "var": "response" } ] }

AND

{   "and": [     { "==": [ { "var": "response" }, "Yes" ] },     { "==": [ { "var": "Supervisor Present" }, "No" ] }   ] }

OR

{   "or": [     { "in": [ "Eye Protection", { "var": "response" } ] },     { "in": [ "Face Shields", { "var": "response" } ] }   ] }

Nested Logic (Advanced)

Operators can be nested for more complex conditions:

{   "and": [     {       "or": [         { "in": [ "Eye Protection", { "var": "response" } ] },         { "in": [ "Face Shields", { "var": "response" } ] }       ]     },     { "==": [ { "var": "Work Area" }, "Shop Floor" ] }   ] }

Additional Details

Job Role: Workflow Manager | Permission Level: Admin (ANVL Manager) + ANVL TECH (ANVL Workflows) | Special Rights: Workflow Management (Create / Edit)

Did this answer your question?