Skip to main content

Conditional Logic

S
Written by Support Engineer

Overview

Conditional Logic lets a form respond to the answers respondents give. You create rules that show, hide, or change whether a field is required, based on what has already been entered. A follow-up question can appear only when it is relevant, a whole page can be skipped when it does not apply, and a field can become mandatory only when it matters. The result is a shorter, smarter form that asks each respondent only what it needs to.

At a high level, working with Conditional Logic involves:

  1. Opening the Logic view in the form builder.

  2. Adding a rule made up of an IF (the conditions) and a THEN (the action).

  3. Previewing it.

  4. Publishing.

Rules run in the respondent's browser as the form is filled in. The same rules also shape the PDF export, so anything hidden on screen is left out of the PDF.

Key Concepts

The following terms are used throughout Conditional Logic:

  • Rule - one IF/THEN statement. Your rules are listed in the Conditions panel.

  • Condition (IF) - a test on one question's answer, for example Country Is "France".

  • Group - a set of conditions joined by AND or OR. Groups can be nested.

  • Action (THEN) - what the rule does when it is true: Show, Hide, Required or Optional.

  • Target - the element an action applies to, such as a question, a form, a page or a sub-page.

Building Your First Rule

  1. Within a Template, switch to the Logic view. You will see the Conditions panel, which reads "No conditions yet" when empty.

  2. Click Add Rule. The rule opens in the Inspector on the right, tagged Rule.

  3. Give it a Name. This is optional, and the placeholder is "Rule name". You can add a Description, or leave it blank to use the auto-generated summary.

  4. Build the IF side under the Conditions heading, and the THEN side under the Actions heading. These are covered in the next two sections.

  5. Click Apply to stage the rule.

Each rule in the list shows a one-line summary of what it does, for example showing one field when another question has a particular answer. A rule with no conditions reads "IF (always)", and one with no actions reads "(no actions)".

The IF Side: Conditions

A condition tests one question's answer. Click Choose Question to pick the source question, then choose a test from the dropdown and enter a value if the test needs one.

Combining Conditions

Add more conditions with Add Condition. Conditions in a group are joined by an AND / OR toggle. The label reads "join with" on the top group, and "group joined with" on nested ones.

  • AND - the rule fires only when every condition is true.

  • OR - the rule fires when any condition is true.

Use the following controls to structure your conditions:

  • Add Group - nests a group, for example "A AND (B OR C)".

  • Wrap - puts a condition into its own group.

  • Ungroup - flattens a group.

There is a limit to how deeply groups can nest. When you reach it, Add Group is disabled and shows the tooltip "Maximum nesting depth reached".

Available Tests

The tests available depend on the type of question you picked. The full set of tests shown in the dropdown is:

  • Presence - Is empty, Has value.

  • Choice - Is, Is not, Is any of, Is none of.

  • Text - Contains, Does not contain, Starts with, Ends with, Length.

  • Address - Is complete, Is incomplete.

  • Email - Domain is, Domain is not.

  • Number - Equals, Not equal, Greater than, Less than, Greater than or equal, Less than or equal, Between.

  • Multi-select - Contains all, Contains any.

  • Toggle - Is true, Is false.

  • Date - Before, After, On or before, On or after.

  • File - File count, File type is, File size.

  • Annotated image - Has annotation, Has stamp, Stamp count.

Entering a Value

The value box adapts to the test:

  • Choice questions show a dropdown ("Select an option" or "Select options").

  • Between shows a From / To pair.

  • File size shows a number with an MB suffix.

  • Dates show a date picker.

  • Other tests show a free-text Value box.

  • When a test needs no value, such as Has value, the value area shows N/A.

The THEN Side: Actions

An action decides what happens when the rule is true. Click the action-type dropdown and pick one of four:

  • Show - reveals the target when the rule is true. Can target a question, form, page or sub-page.

  • Hide - hides the target when the rule is true. Can target a question, form, page or sub-page.

  • Required - makes the target mandatory when the rule is true. Can target a question only.

  • Optional - makes the target optional when the rule is true. Can target a question only.

Pick what the action applies to with the Choose Target picker, and add more actions with Add Action. If you switch an action to Required or Optional while a page or form is selected as the target, the target is cleared, because those actions only work on individual questions.

Seeing Where a Rule is Used

Any question or page that a rule references shows a small link icon on the builder canvas, with the tooltip "Used in 1 rule" (or "Used in N rules").

Because rules depend on those elements, you cannot delete an element or page while a rule references it. Trying to do so opens a "Cannot delete referenced element" (or "Cannot delete referenced page") dialog that lists the rules involved. Each is marked "Used as IF source" or "Used as THEN target", with a "Go to rule" link.

To delete a referenced element:

  1. Open the dialog's Go to rule link.

  2. Update or remove the rule.

  3. Delete the element.

There is no "delete anyway" option, so a rule can never be left pointing at something that no longer exists.

Previewing Your Rules

Switch to the Preview tab to try the form as a respondent would. As you type, rules fire live. When a rule hides an element, Preview shows a dashed placeholder that names the rule, for example "'VAT number' is hidden by rule 'EU customers'", so you can see exactly which rule did what. In the live respondent form the element is simply left out.

If any rule is incomplete, a red dot appears on the Logic tab and you cannot save. You will see the message "Cannot save: some rules have errors. Please fix them and try again." and be taken to the Logic view to fix it. The Inspector lists each problem, for example "A condition is missing a required value".

How Rules Behave for Respondents

  • Hidden field - the field is removed from the form and does not have to be answered. If it is shown again later, it comes back clean.

  • Hidden section or page - it is not rendered. The Previous and Next buttons skip over a hidden page, and going straight to a hidden page by link sends the respondent to the next visible page.

  • Required / Optional - the field becomes mandatory (or not) the moment the rule fires, and reverts to its normal setting when the rule stops applying.

  • Always-visible pages - the Welcome, Return, Review and Score Results pages are always shown. A rule can never hide them.

  • Rule order - rules apply from top to bottom, so a later rule overrides an earlier one for the same target. Within a single rule, Hide wins over Show.

Troubleshooting

  • A "Show" rule is hiding my field when I did not expect it. A Show rule doubles as a hide-by-default: whenever its condition is not true, the target is hidden. If you want a field to stay visible until something specific happens, use a Hide rule triggered by that specific condition instead.

  • My rule does not fire until the respondent enters something. Most tests treat a blank answer as "not matching". Is not, Does not contain, Not equal and similar tests all count as false while the source field is empty. A rule meant to fire until someone enters a value will not fire on a blank field. To handle the empty case, combine it with a Has value or Is empty condition.

  • A number comparison is not behaving. The Is test compares answers as text, so 5 and "5" match. For true numeric comparisons use Equals, Greater than, Less than and so on. Contains matching ignores case.

  • A required field is not blocking submission. A field that a rule has hidden is switched off and does not count towards validation, so a hidden field will not block submission even if it is normally required. If a field must be answered only when it is shown, pair a Show action with a Required action for it.

  • My PDF is missing pages or questions. This is expected. The PDF reflects the same rules as the form, so anything hidden for that respondent is left out of their PDF.

  • I cannot delete a question or page. It is referenced by a rule. Open the "Cannot delete" dialog's "Go to rule" link, update or remove the rule, then delete.

Did this answer your question?