Conditional Logic: Operators and Actions

Note: This is a limited-release feature. It can currently be added to your forms by our Professional Services team. Please contact your ProntoForms account manager for more information.

About

Conditional logic improves the speed and quality of data collection in the field by guiding the mobile user through a workflow relevant to the job's context. This means that they require less training and have a better experience with ProntoForms' product.

Conditional logic is only supported on V2 forms

 

Joining Statements

While the simplest conditional statement is, "If This, Then That," adding complexity to these statements is what makes them extremely useful. It is possible to create a string of conditional logic statements that go through a sequence of conditions and actions to create a desired outcome. Joining these statements can be done in multiple ways.

 

ELSE/IF

This is a fairly simple expansion on the "If This, Then That" statement. If/Else statements allow you to define what happens when the IF statement is not true. Every conditional statement has an ELSE condition. If the ELSE condition is unstated, it is "do nothing."

ElseIf is used within a larger conditional statement to create a sequence of smaller conditional statements to be evaluated individually. If one statement evaluates as TRUE, the sequence will stop: the conditions following the TRUE statement will not be evaluated.

ElseIf statements are best used on single questions with multiple possible outcomes. Using a part of a room inspection form as an 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. 

If you are checking or referencing multiple questions, it's best to use individual conditional statements to check each one rather than sequential ElseIfs.

 

AND/OR

When setting up your conditional logic section, you need to choose if all conditions must be true for the action to happen, or if just one condition needs to be true. This is at the top level and governs all conditional statements beneath it.

AND

This means that all your defined conditions must be true (ie, Q1=5, Q3>05/09/2013) in order for the actions (hide page 3) to take effect.

OR

This means that only one of your defined conditions must be true in order for the actions to take effect.

 

Nesting

You can nest conditions within your conditional logic section to allow AND and OR in the same ruleset.

If [Location] = Warehouse AND ([Type] = Storage OR [Type] = Depot), then SetSectionNotIgnored [Inspection]

 

[ top ]

 

Constructing Conditions

Conditions are statements that evaluate to true or false. If the statement is true - i.e., correct - then something will happen. A condition is the on/off switch for conditional logic.  In our room inspection example, the first condition is:

If the room being inspected equals the common room...

Conditional logic is sequential, meaning that if you are using these conditions to compare this question to another, the question being compared to must appear before the target question. For example:

Valid Condition Invalid Condition
If Q3 = 5 and Q5 = FAIL, then show Q6 If Q3 = 5 and Q5= FAIL, then show Q4.

 

Conditional Operators

Conditional operators are the (usually mathematical) symbols that form part of the condition. Common operators include, but are not limited to: > < =. In our room inspection example, the first condition has an equals operator:

If the room being inspected equals the common room...

Rules for Conditional Operators:

  1. The input question must be a data type compatible with the operator (see tables below).
  2. If comparing to another question, that question's data type must also be compatible with the operator. 
    1. i.e. it is not valid to say "If (integer) = (date/time question)
  3. If comparing to a hard-coded value, it must be of a data type compatible with the operator. 
    1. i.e. it is not valid to say "If (email question) = 5"

Conditional logic validation will catch most conditional operator incompatibilities listed in the following sections.

[ top ]

 

Equals

This conditional operator allows a form-builder to say "If this answer equals exactly this value, then trigger these actions." It can be a hard-coded value, or the answer to another question. This can be a number, a particular sentence or word, or many other user-entered data types.

It is not case-sensitive.

Compatible With: Incompatible With:
Data Types
  • Integer
  • Decimal
  • MonetaryValue
  • EmailAddress
  • PhoneNumber
  • FreeText
  • Yes/No
  • Date, Time, Timestamp
  • Duration
  • URL

Control Types

  • textbox/text area
  • dropdown/radiobutton 
  • button group
  • stepper
  • slider
  • calculation
  • duration calculation
  • aggregation
  • concatenation
  • digit extraction
Data Types
  • Signature
  • Image
  • File
  • GeoLocation
  • Barcode
  • CreditCardTransaction
  • Information
  • Audio
  • Router
  • Magnetic Stripe

Control Types

  • Multiselect

 

GreaterThan or LessThan

These conditional operators allow a form-builder to say, "If this answer is more (or less) than this value, then trigger these actions." This allows form-builders to require users to enter additional information if an inspection score is below a certain value, or set another question's value if an answer is within a certain span.

Compatible With: Incompatible With:
Data Types
  • All Numeric

Control Types

  • textbox/area
  • dropdown/radiobutton 
  • button group
  • stepper
  • slider
  • calculation
  • duration calculation
  • Aggregation

Data type must still be numeric for all.

Data Types

  • EmailAddress
  • PhoneNumber
  • Url
  • FreeText
  • YesNo
  • Signature
  • Image
  • File
  • GeoLocation
  • Barcode
  • CreditCardTransaction
  • Information
  • Audio

Control Types:

  • Multiselect

 

GreaterThanOrEqualTo and LessThanOrEqualTo

These conditional operators check if the value in a numeric question is ≥ or ≤ a hard-coded numeric value or the answer to another numeric question. These options are inclusive: if Q3 ≥ 5 then 5 and over are valid (true) statements. 

Compatible With: Incompatible With:
Data Types
  • All Numeric

Control Types

  • textbox/area
  • dropdown/radiobutton 
  • button group
  • stepper
  • slider
  • calculation
  • duration calculation
  • Aggregation

Data type must still be numeric for all.

Data Types

  • EmailAddress
  • PhoneNumber
  • Url
  • FreeText
  • YesNo
  • Signature
  • Image
  • File
  • GeoLocation
  • Barcode
  • CreditCardTransaction
  • Information
  • Audio

Control Types:

  • Multiselect

 

Between

This conditional operator checks if a value is within a certain range of numbers, i.e., 50 < Q3 < 75.

Compatible With: Incompatible With:
Data Types
  • All Numeric

Control Types

  • textbox/area
  • dropdown/radiobutton 
  • button group
  • stepper
  • slider
  • calculation
  • duration calculation
  • Aggregation

Data type must still be numeric for all.

Data Types

  • EmailAddress
  • PhoneNumber
  • Url
  • FreeText
  • YesNo
  • Signature
  • Image
  • File
  • GeoLocation
  • Barcode
  • CreditCardTransaction
  • Information
  • Audio

Control Types:

  • Multiselect

 

Contains

This conditional operator checks if a phrase matching certain criteria is contained within the question's answers. This phrase can be words, numbers, names, or times. For example, if Q1 contains "broken", then show Q5 (Describe what is broken).

Compatible With: Incompatible With:
Data Types
  • All Numeric
  • Alphanumeric
  • email
  • URL
  • Date
  • Time
  • Timestamp

Control Types

  • textbox/area
  • dropdown/radiobutton 
  • button group
  • stepper
  • slider
  • calculation
  • duration calculation
  • Aggregation
  • Multiselect
  • Concatenation*
  • Digit Extraction

Data Types

  • Information
  • Attachments
  • Mag Stripe
  • Credit Card Transaction
  • Yes/No
  • URL
  • Geo

 

Supported Actions

If conditions are the on-off switch, then actions are the circuitry: actions dictate what happens when a condition is true. In ProntoForms' case, actions can hide a page, make a question required or not required, and other actions - essentially, they change the user's path through the form.

Actions can be stacked to cause multiple changes based on one condition being true. In our room inspection 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.

 

Rules for Actions

  1. Actions must be valid for the question/item that is being acted on (see below).
  2. Actions must be performed on pages/sections/questions that occur after ALL the inputs (i.e., sequential).
Action Name Compatible Data Types Incompatible Control/Data Types Notes

SetQuestionVisible

SetQuestionNotVisible 

 All None The question becomes visible/invisible on the device. If set Visible, the question will show any default values, and if set Required, will require an answer as normal.

If set NotVisible, the question is hidden from the mobile user. If data has been entered, it will remain and will be submitted, and can be used for downstream calculations.

SetPageNotIgnored

SetPageIgnored

All None

Data on Ignored pages:

  • Will not be submitted
  • Does not exist for mobile users
  • Cannot be used for downstream calculations

Page/Section Ignored overrides any question-level logic. Any Required questions will be ignored.

SetSectionIgnored

SetSectionNotIgnored

All None

Data on Ignored sections:

  • Will not be submitted
  • Does not exist for mobile users
  • Cannot be used for downstream calculations

Page/Section Ignored overrides any question-level logic. Any Required questions will be ignored.

ClearQuestionValue

All None

This clears the question value (essentially "delete"). It also clears the default value of the question, if set.

Uses questionLabel

ResetQuestionValue

All None

This resets the question value to the default value.

Uses questionLabel

 

Action Name Compatible Data Types Incompatible Control/Data Types Notes

SetQuestionRequired

SetQuestionNotRequired 

  • Alphanumeric
  • Numeric (except calculations and math)
  • Duration
  • Barcode scan
  • Email
  • URL
  • Dates, times, date/time
  • Attachments
  • Multiselect (control)
  • Information (no user input allowed)
  • Calculation
  • Date/Time Math
  • Digit Extraction
  • String concatenation
  • Geostamp
  • Yes/No
Uses questionLabel

SetQuestionReadOnly

SetQuestionNotReadOnly

  • Alphanumeric
  • Numeric (except calculations and math)
  • Duration
  • Email
  • URL
  • Dates, times, date/time
  • Multiselect (control)
  • Information (no user input allowed)
  • Calculation
  • Date/Time Math
  • Digit Extraction
  • String concatenation
  • Geostamp
  • Yes/No
Uses questionLabel

SetQuestionValue

  • Alphanumeric
  • Numeric (except calculations and math)
  • Multiselect (control)
  • Information
  • Attachments
  • Geostamp
  • Yes/No

You can set a hardcoded value, but cannot import a value from another question.

If setting the value of a dropdown/radiobutton/button group, the set value must match one of the question's options.

If setting a currency value, do not add a $ before the value.

The value set must be within validation rules for the question or data type. i.e. a numeric question cannot be set to "Fail"

Uses questionLabel

[ top ]

 

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

Comments