Conditional Logic: Troubleshooting

 

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

 

About

While conditional logic in forms simplifies mobile users' workflow, as you build more complex conditional logic into forms there are more opportunities to make mistakes in building it. This article is a best practices guide and will discuss a number of potential pitfalls when building conditional logic forms.

Conditional logic can only be used with V2 forms.

 

Evaluating a Single Logic Rule

The Form Builder prevents most errors that are contained within a single conditional logic rule.  In most simple cases, the Form Builder will only let you deploy the form if the rule is valid.  

 

Errors that will prevent you from saving a form: 

In your IF Statement...

  • You have an incompatible reference question/operator combination
  • You are comparing a reference question to an incompatible constant or question
  • A question referenced is not in a valid part of the form for comparison (it is inside of a repeatable section, and the conditional logic is written at the form level)

In your THEN Statement...

  • You are performing an action that is invalid for the action target (the page, section or question that you are acting on)
  • You are setting a question to an invalid constant or data type
  • The action target does NOT appear in the form after all the elements in your "If"
  • The action target is in an area of the form that is not valid to be acted on (it is inside of a repeatable section, and the conditional logic is written at the form-level, rather than within the repeatable section

 

Errors that you must check for:

The Form Builder is currently unable to check for these issues.

  • Elements of your IF statement contradict each other
    • I.e. You have not set up the rule so that it can never be true
    • Example: 
      • IF Q1 = 5 AND Q1 = 8 
  • Elements of your THEN statement contradict each other
    • I.e. You have set up the rule so that it is impossible for the action occur
    • Example: 
      • THEN Q1 is visible AND Q1 is not visible

[ top ]

 

Evaluating Your Conditional Logic as a Whole

The Form Builder validates that each individual rule is valid, but it does not validate conditional logic rules against one another.  As you are building more complex conditional logic into a form, there are a number of things to watch out for. 

When you have many conditional logic rules, the easiest way to get an overview of them is in the Web Portal. See here for more information. 

 

Conflicting Conditional Logic Rules

Watch out for conditional logic rules that overwrite the action of another rule.

RULE 1:     IF Q1 = 5
                 THEN Q3 is Visible
                 ELSE Q3 is Not Visible
RULE 2:    IF Q2 <3
                THEN Q3 is Not Visible
                 ELSE Q3 is Visible

In the example above, while each rule is perfectly valid on its own, Q3 will have strange behaviour.  If Q1 does equal 5, and Q2 is indeed less than 3, the visibility of Q3 will depend on which question the mobile user last interacted with -- so if they last modified Q1 that is the rule that will control the behaviour.

It would be best to rewrite this as a single rule:  
     IF Q1 !=5 AND Q2 <3
     THEN Q3 is Not Visible
     ELSE Q3 is Visible

[ top ]

 

Troubleshooting Inconsistent Form Behaviour

When building conditional logic, remember that conditional logic is not the only thing acting on a form -- your field users are as well!  Remember that the behaviour of mobile users will always have more of an impact on the outcome of a form than conditional logic does.

 

Users overwriting your conditional logic outcomes

Imagine you have a form with the rule below.

IF Q1 < 50
THEN Q3 is set to "Fail"
ELSE Q3 is set to "Pass"

After using the form successfully in the field for a while with no issues, you receive a form submission where Q1 had the answer of 30 (a very failed inspection), yet Q3 is marked as "Pass."   

What happened?   

  • First, check your conditional logic
  • If there are no rules that would have overwritten this, it's highly likely that the mobile user manually changed the answer of Q3.    

If you are conditionally setting the values of a question, it's best to make sure that question is also Read-Only (conditionally or not) -- unless you are okay with users making manual changes to it.    

[ top ]

 

 

 

Else:  What happens when users change their minds? 

As conditional logic affects the workflow a user sees, it is important to think about what happens when a user goes back and changes an answer. This section will discuss best practices to avoid confusion or showing unnecessary information based on answers being changed.

 

ELSE Actions must include undoing all IF Actions

When building conditional logic workflows it is important to keep in mind what happens when an answer is changed, and build appropriate actions into all ELSE conditions. Using our room inspection example:

  • If the room gets a score of less than 50, the inspection has failed. Users will then see a Required Comments section, and see Page 2, which contains questions for failed inspections.
  • If the room gets a score of above 50, the inspection passes and the Required Comments section is not shown/available, nor is Page 2.
  Conditional Statement Result
"Good" ELSE If Q1 <50
  • Set Q2 to "Fail"
  • Show Page 2
  • Show Q3
  • Set Q3 to Required
Else
  • Reset Q3
  • Hide Page 2
  • Hide Q3
  • Set Q3 Not required

This "ELSE" defines what to do if Q1 is not <50. This causes the following sequence:

  1. User sets Q1=45
  2. First set of actions fires
  3. User changes their mind, sets Q1=70
  4. ELSE actions undo the earlier actions, reverting them to a default state.

 

"Bad" ELSE  If Q1 <50
  • Set Q2 to "Fail"
  • Show Page 2
  • Show Q3
  • Set Q3 to Required
Else
  • Reset Q3

 This "ELSE" condition only works on the first encounter with the question. The sequence would be: 

  1. User sets Q1=45
  2. First set of actions fires
  3. User changes their mind, sets Q1=70
  4. ELSE action will say "PASS", but the other actions will remain "active". The user will still see:
    • Q3
    • Page 2

[ top ] 

 

Ignored vs. Not Visible: What's the Difference? 

Pages and Sections can be ignored, while Questions can be made visible/not visible.   Read more about the available actions in conditional logic here.  Understanding this concept is important if you are building complex forms.  

Remember that:

  • Data in "Ignored" parts of the form does not exist as far as the form is concerned
    • It will not be visible to mobile users
    • It will not push information to subsequent fields in the form
    • It will not be used in calculations, filters, etc in subsequent fields in the form
    • It will be considered empty if referenced in conditional logic rules
    • It will not be submitted to the web portal so that it can be reviewed in results
  • Therefore, "Ignoring" a page can cause major downstream impacts in a form.

  • Data in "Not Visible" question does exist as far as the form is concerned
    • Mobile users will not see it, but...
    • It can still push information to other questions
    • It will be used in calculations, filters, etc in subsequent fields of the form
    • It's value will be used if it is referenced in conditional logic rules
    • It will be submitted to eh web portal
  • Therefore, the action of making a question "Not Visible" doesn't affect the downstream flow of the form as much, but the data in it does still affect the form.

 

What if I want to "Ignore" a question? 

If you want a question to be conditionally not visible to users, and you don't want to keep the data in it when it is hidden, here are your options. 

  1. Place the question in a section that you will "Ignore" instead
  2. Or, the conditional logic rule that sets the question to "Not Visible" should also "Reset" the Question at the same time. 

 

 

What if I want a Page or Section to be Not Visible, but I want to use the data in it?

This isn't really possible.  We recommend making a series of questions "Not Visible" instead. 

[ top ] 

 

Dispatching into Forms with Conditional Logic

When you dispatch a form with conditional logic, the conditional logic will execute when the user opens the form, to get it into an appropriate starting state (as specified by your conditional logic rules).

 

Dispatched Data on Ignored Pages and Sections

In the normal flow of using a form, if a user activity "Ignores" a page or section that already has information in it, that data will "exist" again once the page or section is "Not Ignored".


However, if a page or section is set to "Ignored" as the form is first opening, any information dispatched into those pages will be cleared; so if a user action sets that section or page to "Not Ignored", that information will not exist. 

If you need to dispatch information into Pages/Sections that can be "Ignored" in the form, ensure that they are "Not Ignored" in the starting state of the form, and that only a mobile user action will trigger them to be "Ignored." 

 

Dispatched Data Being Overwritten by Conditional Logic Rules

Again, when a user opens up a form that has been dispatched to them, conditional logic runs to determine the starting state of a form.

If the "dispatcher" dispatched a value of "Pass"  into a field in the form, but mobile users are reporting they did not receive that value, it is likely that a conditional logic rule is clearing/resetting/changing the value of that question as the form opens on the device.

 [ top ] 

 

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

Comments

  • Avatar
    Robert Oliver

    When will the V2 Form builder be available?