Skip to content

Logic

Logic is a set of rules that look at the answers so far. Each rule is an expression that gives true or false, or a value. You can write the expression, or build it with the condition builder, which shows it as Field, an operator and Value.

Foldr runs every rule in the browser as the person fills in the form, and again on the server when they submit. Answers to hidden questions are dropped on the server.

Open Logic & validation on a question.

RuleGivesEffect
Show this question whentrue or falseThe question is hidden until it is true.
Required whentrue or falseThe question must be answered while it is true.
Valid whentrue or falseThe answer is refused unless it is true.
Computed value (read-only)A valueThe answer is worked out and the respondent cannot change it.
Default value (editable)A valueThe answer starts as this and can be changed.
Logic and validation: the condition builder on Show this question when
Logic and validation: the condition builder on Show this question when
{"answers": {"source": "Other", "vat_registered": true, "vat": "GB123456789"}}

Show a text box when someone picks “Other”:

answers.source == "Other"
true

Require a VAT number only for businesses that are registered:

answers.vat_registered == true
true

Check the shape of the number:

answers.vat matches /^GB[0-9]{9}$/
true
Choosing Other reveals a follow-up question

The two rules Required when and Valid when, on a VAT number question:

Required when and Valid when on the VAT number question
Required when and Valid when on the VAT number question

A Panel and Columns have a Show this panel when and a Show these columns when. Hiding one hides everything inside it.

Add condition picks a Field, an operator and a Value. Add group combines conditions with Match all or any of the following. Edit as expression shows the written form. A condition that the builder cannot show opens as a Custom expression.

The operators depend on the type of question: is, is not, greater than, at least, less than, at most, is empty, is answered, includes, does not include, and for dates is on, is not on, is before, is after.

Adding a condition, from Add condition to the chosen value:

Condition builder: show Please say what you supply only when What do you supply? is Other

A condition shown as an expression, with a link back to the builder:

A condition written as an expression, with a link back to the builder
A condition written as an expression, with a link back to the builder

A Page break has Skip logic. When a respondent finishes the page above, the first matching rule decides where they go: Go to a page, or Finish (submit the form), when this is true. If no rule matches, they continue to the next page. Turn off Show the page progress bar (in Settings > Look & options) when skipping makes a linear count misleading.

Skip logic on a page break: go to a page, or finish, when a condition is true
Skip logic on a page break: go to a page, or finish, when a condition is true
Skip logic: not VAT registered goes straight to Products

A variable is named state for the form. In Settings > Behaviour > Variables, choose Add a variable, and give it a Key, a Type (text, number or yes/no) and a Default. Read it in any rule as vars.key.

Variables let a button, or a change in one answer, show or hide parts of the form.

{"vars": {"show_extra": true}}
vars.show_extra
true

A variable key must be unique, in letters, numbers and underscores, and not start with a number.

The Variables card
The Variables card

A Button question runs its On click actions. A question can also run actions When this answer changes, and the form can run actions When the form opens.

ActionDoes
ToggleFlips a yes/no variable or field.
SetSets a field or a variable to value or to expression.
ResetPuts a field or a variable back to blank or its default.
Run automationRuns an approved script and puts what it returns into fields, into variables, or both. See Data sources and lookups.

When the form opens is for seeding a variable or pre-filling a field. It runs once, when someone opens the form.

The When the form opens card
The When the form opens card
A button toggles a variable and a panel appears

A Button with its On click actions:

A Button question with its On click actions
A Button question with its On click actions

In Settings > Behaviour > Submit button:

SettingDoes
Button textThe words on the button. The default is Submit.
Show the submit button when…Hides the button until the expression is true. Empty means always show. Example: vars.agreed == true.
Enable the submit button when…Greys the button until the expression is true. Empty means enable it once the required fields are filled. Example: answers.total > 0.
The Submit button card: label and when it shows or is enabled
The Submit button card: label and when it shows or is enabled

Text in a label, help text or Text / HTML block can include {{ answers.key }} or {{ vars.key }}. Any expression works inside the braces.