Building Conditional Logic Rules

 

Note: This feature is coming soon and is not yet generally available.

 

About

Conditional logic 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.

This articles discusses how to build conditional logic rules into your forms. These define how the mobile form behaves (what parts of the form are hidden, shown, required, etc) based on the information provided by mobile users.   

 

 

 

A sample conditional logic rule:

 

[ top ]

 

Create a Conditional Logic Rule

  1. Edit the form to open it in the Form Builder. 
  2. Navigate to the Conditional Logic tab.
  3. Click on the Add a Rule button in the left navigation drawer.
  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. Configure the If, Then, and Else Statements as described below.

[ top ]

 

"If"

This is the condition/set of conditions that must be met in order for any actions (the "Then") to take place. 

 

Every "If" Condition must contain the following: 

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

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, radiobutton, multiselect, or button group question with options "defined here", you can select those options from the IF dropdown.

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.

Possible Operators:

  • 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) that you will compare the reference question to.

 

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, or button group question with options "defined here", you can select those options from the dropdown.

[ top ]

 

"If" Conditions with Multiple Rules

An If Condition can contain multiples rules, and you can specify whether ALL or ANY of the rules must be true in order for the condition to be true and the "Then" actions to take place.  

 

How to create an IF condition with multiple rules:

  1. Choose AND if you want all rules 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 rule.

 [ top ]

 

"If" Conditions with Bracketed/Nested Rules

It is also possible to build more complex conditions that involve multiple join rules.  

For example, you could evaluate the following condition, where one simple rule could cause the "Then" actions to occur, or a combination of two other rules could cause 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

 

How to create Bracketed/Nested Rules:

  1. Build an "If" condition with at least two rules, as described above.
  2. Notice that after each individual rule, within the same coloured block, there is an operator that is the opposite of the current join rule.
  3. Press this to add a bracketed rule.

 [ top ]

 

"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

 

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.

 

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.  

  • 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. 

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, or button group question with options "defined here", you can select those options from the dropdown.

[ top ]

 

 

"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 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.

2017-08-24-V2FB-AutoElse.png

 

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

2017-08-24-V2FB-AutoElseDisable.png
[ top ]

 

 

"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 behaviour 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. 

 

[ top ]

 

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. 

[ top ]

 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

  • Avatar
    Phil Bullock

    How do you say "IF 'Text Field' IS ANSWERED" then change another field to visible.  The only options I get are "equals," "does not equal," or "contain."

  • Avatar
    Danielle Morley

    Hi Phil,

    Thanks for your comment.  Currently, checking if a question is "answered" or "not answered" is not a supported feature -- however, it is coming soon!