Building Conditional Logic Rules

Applying conditional logic adds intelligent automation to your mobile forms. You can use conditional logic to provide context for your field technicians, enhance their effectiveness, and enforce a workflow. This topic describes how to build and activate conditional logic rules.

Supported on the Advanced and Enterprise tiers:

Essentials
Advanced
Enterprise

Contents

About

Conditional logicClosed Conditional logic is a tool in the Form Builder that establishes the workflow of a form. By using the "If This, Then That" structure, questions or sections will be displayed, hidden, or automatically populated based on answers to preceding questions. uses "If This, Then That" statements to add intelligent automation into forms, guiding users of a form through a workflow depending on their context. Read more general information about conditional logic.

Create a Conditional Logic Rule

  1. Edit the form to open it in the Form Builder.

  2. Navigate to the Conditional Logic tab.

  3. Select Add a Rule in the left navigation.

    Select "Add a Rule" in the Form Builder

  4. Configure a Rule Name.

    • This is a required field, 50 characters or less, and it must be unique within the form

    • Shows up in the side navigation

    • Should give an overview of what it affects, making it easy to spot the desired rule when you want to edit or troubleshoot your conditional logic in the future

  5. Optionally provide a Rule Description.

    • This is highly recommended but optional, and can be up to 255 characters

    • Should be a more detailed overview of how the rule works and what it affects. Again, this is helpful for future editing, troubleshooting, or helping others understand how the form is supposed to work.

  6. By default, the new rule is active. If you want to test your form without the rule, toggle Rule Active to the off position (left).

  7. Configure the If, Then, and Else statements as described below.

"If" statement

This is the condition/set of conditions that must be met in order for any action to take place.

Every "If" Condition must contain the following: 

  1. Reference Question
  2. Operator
  3. Comparison Value or Question

If statement that shows the reference question "Is inspection required" with the operator "equals" and the comparison question value the constant "Yes"

Reference question

This is the question that you will be comparing. Only some types of questions are allowed to be used as a reference question. If you are using a Dropdown, Radio Button, Multiselect, Card List, or Button Group question with options "defined here", you can select those options from the IF dropdown.

The drop-down menu for selecting a reference question

Only questions with the following data types can be used as a reference question:

  • Freetext
  • URL/Email/Phone Number
  • Integer/Decimal/Currency
  • Duration
  • Date, Time, and Date/Time

The questions that are available to you will be restricted based on the above types. If the list is still large, begin typing a question identifier or question text to filter the list of available questions.

Operator

This is how you will be comparing the reference question to the comparison value or question.

The drop-down menu to select an operator

Possible operators include:

  • equals/does not equal
  • contains
  • is less than/is greater than
  • is less than or equal to/is greater than or equal to
  • is between

The operators that are available to you will be restricted based on the data type of the reference question you choose. For example, a "Freetext" data type cannot be "less than" anything. Review the list of what operators are valid for which question types and the full definitions for each operator.

Comparison value or question

This is the value (a constant or the answer to another question) to compare to the reference question.
The drop-down menu to select a comparison value or question

Compare to a constant:

  • Simply type in the value you would like to compare it to, like "70" or "Pass.""
  • The value must match the data type of the question.
  • For example, you cannot compare a question with an Integer data type to the word "Pass."

Compare to a question:

  • Select a question from the list. The available questions will be limited to those with a matching data type. Optionally begin typing to filter the list of available questions.
  • If you are using a Dropdown, Radiobutton, Multiselect,Card List,or Button Group question with options "defined here", you can select those options from the dropdown.

"If" Statements with Multiple Conditions

An If statement can contain multiple conditions, and you can specify whether ALL or ANY of the conditions must be true in order for the statement to be true and trigger the "Then" action.

To create an IF statement with multiple conditions:

  1. Choose AND if you want all conditions to be true in order for the actions to take place, or choose OR if you want any of them to be true in order for the actions to take place.

  2. A new block will appear underneath, separated by an AND or OR (whichever you chose). Configure the new condition.

"If" Statements with Sets of Conditions

It is also possible to build more complex statements that involve multiple conditions. For example, you could evaluate the following statement, where one simple condition could cause the "Then" actions to occur, or a set of two other conditions could trigger those actions:

If Total Inspection Score is less than 70 OR (Total Inspection Score is less than 80 AND Customer Satisfaction is less than 70)

Then Inspection Failed is not ignored

To create sets of conditions:

  1. Build an If statement with at least two conditions, as shown in the following example.

    If statement that shows two conditions: If "Is inspection requried?" = Yes AND if "Room being inspected" = Common Area

    Result: The Then action is triggered when an inspection is required and the room being inspected is the Common Area.

  2. Once you have at least two conditions defined, you can create different sets of conditions. To create a set of conditions, select the opposite “join” option.

  3. As you continue to add conditions, the Form Builder uses brackets and shading to show the structure of nested sets of conditions:

    Example "If" statement with nested OR conditions within an AND condition.

"Then"

"Then" is a list of actions; it controls what happens in the form when the "If" is true.

Every "Then" statement must contain the following: 

  1. An action target
  2. An action
  3. For some actions, a target value

Select "Then" statement actions

Action Target

This is the page, section or question that you would like to affect with conditional logic.

NOTE: Any action target (whether it is a page, section or question) must appear in the form AFTER every single question reference or comparison question that is in your "If" condition.

Select an action target for the "Then" statement

Action

This is what should happen to the action target -- what about it should be changed when the "If" is true. All action targets you use must come after ALL of the questions referenced in your "If" statement.

Select an action for the "Then" statement

  • Pages and sections:
    • Can be made ignored or not ignored.
  • Questions:
    • Can be made visible or not visible (any question type)
    • Can be reset or cleared (most question types)
    • Can be made required or not required (many question types)
    • Can be made read-only or not read-only (many question types)
    • Can be set to have a specific value (like "Pass" or "50") or be set to the value collected in another question (some question types)

The list of available actions will be filtered based on the type of action target (page, section, or type of question) that you chose. Review the full list of what actions are allowed, as well as the full definition of the actions.

Target Value

This field will only appear if you have selected "is set to" as the action. This is the value you would like your action target to be set to, if your "If" statement is true.

Select a target value for the "Then" statement

Set to a constant:

  • Simply type in the value you would like to set the question to, like "70" or "Pass."
  • The value must match the data type of the question. For example, you cannot compare a question with an Integer data type to the word "Pass."

Set to the answer of a question:

  • Select a question from the list. Optionally begin typing to filter the list of available questions 
    • The available questions will be limited to those with a matching data type.
    • The question must come BEFORE the action target in the form. 
  • If you are using a Dropdown, Radiobutton, Multiselect,Card List,or Button Group question with options "defined here", you can select those options from the dropdown.

"Else"

The "Else" statement contains a list of actions that should happen when your "If" statement is NOT true.

Every "Else" statement must contain the following: 

  1. An action target
  2. An action
  3. For some actions, a target value

"Else" statements are built in exactly the same way as "Then" statements.

Why build an "Else" statement?

"Else" statements are necessary because mobile users will make mistakes or change their mind. If they initially make a choice in the form that shows a page and makes a question required, but then changes their mind, the "Else" statement needs to be able to hide the page and make the question not required.

In most cases the "Else" statement should simply do exactly the opposite of what your "Then" statement did.

Opposite Actions

Below is a list of actions that you might put in a "Then" statement, and their corresponding opposite actions that should be in the "Else."

"Then" Statement "Else" Statement
page is ignored is not ignored
section is ignored is not ignored
question is visible is not visible
question is set to is reset (or is cleared)
question is required is not required
question is read-only is not read-only

Auto-Generating "Else" Statements

If you only have one "If" statement in a conditional logic rule, the "Else" statements can be auto-generated. These will be the opposite actions (as listed in the table above) of the "Then" statement. If your conditional logic rule contains an "Else If" statement, the "Else" statements cannot be auto-generated.

Display for auto-generated "Else" statements

This functionality speeds up the creation of conditional logic rules. However, it can be disabled or overridden by selecting "Custom Actions":

Select custom actions for the "Else" statements

"Else If" Statements

"Else If" statements are optional, and not needed for most conditions.

An "Else if" statement is an additional "If/Then" statement in the same conditional logic rule as another "If/Then". The "Else If" statement is only tested when the original If statement is NOT true.

A single  conditional logic rule can have several "Else If" statements. If one statement evaluates as TRUE, the additional "Else if" statements following the TRUE statement will not be evaluated.

Example:

If the room being inspected equals the common room, then show the "common room" section, hide the "washroom" section, and hide the "warehouse" section.

Else If the room being inspected equals the washroom, then show the "washroom" section, hide the "common area" section, and hide the "warehouse" section.

Else If the room being inspected equals the warehouse, then show the "warehouse" section, hide the "common area" section, and hide the "washroom" section.

Else, hide the "common room" section, hide the "washroom" section, and hide the "warehouse" section. 

Why build an "Else If" statement?

"Else If" statements are especially useful if you are testing a question/group of questions where there are more than two mutually exclusive possible outcomes.

  • Sometimes, it is not possible to build separate conditional logic rules to accomplish this because they may conflict.
  • "Else If" statements help organize related but mutually exclusive conditional logic behavior under a single rule, making it easier to manage and modify the logic. 
  • If you have a lot of conditions like this, performance on mobile devices can be improved by using "Else if" statements to reduce the number of conditional logic rules. Try to put the scenario the form will launch in as the first "If" statement to improve performance more.

Testing and Troubleshooting

Conditional logic is very powerful and configurable, but it does introduce some complexity as well as more ways that things can go wrong. When you make changes, we highly recommend you test the following before deploying it to production, to ensure that everything behaves as expected:

  • Every condition and every possible path through the form.
  • What happens if you "undo" an answer that triggers conditional logic.
  • If you added a lot of new rules, test on the oldest/lowest memory mobile device that your field users may be using.

You may want to deactivate conditional logic rules for testing purposes yet retain the rule configuration in the form.

To deactivate a conditional logic rule:

  1. Edit the form to open it in the Form Builder.

  2. Navigate to the Conditional Logic tab.

  3. Select the rule from the left navigation.

  4. Toggle Rule Active to the off position (left).

    List of conditional logic rules with an icon that shows "Brake Light Images" as inactive. This also shows the "Rule Active" toggle set to the off position (left).

Info:The icon next to the rule name in the left navigation indicates an inactive rule. The topic Viewing Form Details describes the Pages & Questions tab, which also indicates inactive rules.

To reactivate the rule, toggle Rule Active to the on position (right).