Conditions and logic
Modify your flow's behavior using answers collected.
Last updated
Modify your flow's behavior using answers collected.
Last updated
Conditional logic is useful for making flows dynamic and more personalized; rather than creating multiple flows for different scenarios, flow questions, steps, and groups can be rendered dynamically based on the answers the responder has provided.
Conditional logic can be used to control the enablement of many items in the flow, such as:
When setting up the form logic for questions, groups, and steps, it is important to understand that the user experiences the flow according to the order you establish in the Content Editor, from Step 0 to the final step. When logic is applied to any group/step/question element, this order can be manipulated since the logic will either render or hide that item.
Applying logic involves adding logical arguments that evaluate to either True or False. If the statement is True, the element is enabled. If the statement is False, the element will be removed.
Using logic will not "pull" users to particular steps -- they will not go from Step 1 to Step 30 by adding logic to Step 30.
Conditional logic merely hides or renders elements as the user moves from Step 1 -> finalize.
View this flow setup:
A question is posed at Step 1: Do you have a cat or a dog?
If the user answers cat: the logic at Step 2 is True, and Step 2 is shown; Step 3 is false and will be hidden. Once Step 2 is completed, the user does not see Step 3.
If the user answers dog: the logic at Step 2 is false, and Step 2 is hidden; the user moves on to Step 3, which has evaluated to True.
This is a simple but common example, and illustrates well how the user experience is manipulated based on the step logic evaluating to True or False.
At it's most basic, the simple logic editor can accept one argument to determine whether or not to enable a specific item.
A logical argument is built using three parts:
The variable (answers, external variables, etc);
The logical operator (see our logical operator documentation for reference);
The expected value of the variable.
In the picture above, we are using an external variable value to determine whether or not to render the first step: If our external variable value equals "facebook", the step is rendered.
The studio will only accept logic that is dependent on variables that will have been previously defined in the form. This means you cannot add logic to Step 1 based on an answer that will become defined at Step 3.
If the conditional rendering of your step depends on more than one condition being satisfied, the simple logic editor can accept several arguments using the +Add condition button in the simple logic menu.
You can also nest the logic of conditions by grouping (+Add group) the logic.
If you find that you are adding many multi-clause conditions, you might be beyond the scope of simple logic and should check out our calculated variables instead.
If the logic you are trying to express involves a combination of multiple different answers, you can use advanced logic to define arbitrary boolean expressions over the answers.
To learn more about advanced logic, see our advanced logic sub-section.
For even more complicated conditional logic, define a boolean
(True/False) calculated variable, which allows you to use arbitrary Typescript to create conditional a True/False return, which can then be used in a simple logic check.
Toggling on Optional? for a Question allows users to move past a question without answering it. The default behavior for Formsort flows is to let users progress only when all questions have been satisfied; optional can override this.