Skip to content

Logic

Logic decides where a respondent goes next. Without rules, a form shows its pages in order and ends on the first end page. A rule can send the respondent to another question or to an end page, depending on answers, hidden fields and variables.

Rules are kept in logic. The same list also holds the calculations that change variables. Logic is available from the Essential plan up.

logic is a list of blocks. A block belongs to one question and holds all rules of that question.

KeyTypeDescription
typestringcomponent for the rules of a question. hidden for the one block that runs when the form starts. See Rules at the start.
refstringref of the question that owns the rules. For a question in a group, the ref of that question, not of the group. Empty for the hidden block.
actionsarrayThe rules: jumps and calculations in one list.

A question has at most one block.

Each item of actions has three keys.

KeyTypeDescription
actionstringjump moves the respondent. add, subtract, multiply and divide change a variable and are described in Variables and scoring.
conditionobjectWhen the action applies. See Conditions.
detailsobjectWhat the action does.

There are no other actions. In particular, a rule cannot hide a question: to skip questions, jump over them.

details.to names the target.

to.typeto.valueResult
componentref of a questionThe respondent goes to that question. When the question is in a group, they go to the page of the group.
end_pageref of an end pageThe response is submitted and that end page is shown.
{
"type": "component",
"ref": "c3a9e1b7-5f24-4d68-8e0b-1a7c6d9f2e53",
"actions": [
{
"action": "jump",
"condition": {
"op": "is",
"vars": [
{ "type": "component", "value": "c3a9e1b7-5f24-4d68-8e0b-1a7c6d9f2e53" },
{ "type": "choice", "value": "5d2f8c41-9b7e-4a13-a6c0-2e4f6b8d0a17" }
]
},
"details": { "to": { "type": "end_page", "value": "c41d7a90-2e6b-4b35-9f08-6a1c3e5d7b92" } }
},
{
"action": "jump",
"condition": { "op": "always", "vars": [] },
"details": { "to": { "type": "component", "value": "9d0b2c4e-6a81-4f37-b5c9-0e2a4c6f8b13" } }
}
]
}

This block reads: when the respondent picks the first option, finish on the given end page. In all other cases, go to the given question.

A condition has an operator in op and its operands in vars. There are three forms.

FormShape
Always{ "op": "always", "vars": [] }
Comparison{ "op": "<operator>", "vars": [ <left>, <right> ] }
Group{ "op": "and" } or { "op": "or" } with a list of conditions in vars

The left operand is the thing being tested.

Left operandTests
{ "type": "component", "value": "<question ref>" }The answer to a question.
{ "type": "hidden", "value": "<name>" }A hidden field.
{ "type": "variable", "value": "<name>" }A variable.

The right operand is what it is compared with.

Right operandUsed for
{ "type": "choice", "value": "<option ref>" }An option of the question on the left.
{ "type": "constant", "value": … }A text, a number, true or false, or a date as YYYY-MM-DD.
FamilyOperatorsRight operand
Textequal, not_equal, starts_with, ends_with, contains, not_containsText.
Choiceis, is_notAn option.
Yes or nois, is_nottrue or false.
Numberequal, not_equal, lower_than, lower_equal_than, greater_than, greater_equal_thanA number.
Dateon, not_on, earlier_than, earlier_than_or_on, later_than, later_than_or_onA date.
Answeredansweredtrue.

Text comparisons are case-sensitive. A comparison with a question that has no answer is false, also for the negative operators not_equal and is_not.

SourceFamily
text, mail, website, dropdownText. For a dropdown, the right operand is the label of the option.
multiple_choice, picture_choiceChoice. With multiple selection, is is true when the option is among the picked ones.
yesno, legalYes or no.
number, rating, customer_sat, opinion_scaleNumber.
dateDate.
file_upload, signatureAnswered.
Hidden fieldText.
VariableNumber.

The answers of phone_number, matrix, ranking, slider, numbers_scale, constant_sum and semantic_differential questions cannot be tested. These questions can still own rules that test other things, and they can be the target of a jump.

A rule of a question can test that question and the questions before it, every hidden field and every variable. It cannot test a later question.

and and or combine conditions. The editor shows a flat list, “A and B or C and D”, and stores it with and binding tighter than or:

{
"op": "or",
"vars": [
{ "op": "and", "vars": [ { "op": "equal", "vars": [ … ] }, { "op": "equal", "vars": [ … ] } ] },
{ "op": "and", "vars": [ { "op": "equal", "vars": [ … ] }, { "op": "equal", "vars": [ … ] } ] }
]
}
  1. Rules run when the respondent leaves a page.
  2. Calculations of the page are applied first. A jump on the same page can therefore test a variable the page has just changed.
  3. Jumps are checked in the order of actions. The first jump whose condition is true wins. The editor stores the “in all other cases” jump last.
  4. On a group page, the rules of each question in the group are checked in order, and again the first true jump wins.
  5. A jump to a target that no longer exists is ignored.
  6. Without a matching jump the respondent goes to the next page, or, after the last page, to the first end page.

A jump can point backwards. The respondent then answers the earlier pages again, and the calculations of the pages after the target are dropped.

One block can have the type hidden. It runs once, when the form starts, and can test hidden fields. Use it to route respondents by a value in the link:

{
"type": "hidden",
"ref": "",
"actions": [
{
"action": "jump",
"condition": {
"op": "equal",
"vars": [
{ "type": "hidden", "value": "plan" },
{ "type": "constant", "value": "pro" }
]
},
"details": { "to": { "type": "component", "value": "9d0b2c4e-6a81-4f37-b5c9-0e2a4c6f8b13" } }
}
]
}

A jump to a question opens the form on that page. A jump to an end page submits the response at once and shows the end page. A/B testing uses this block with the hidden field ab_testing.

  • Quotas send a respondent elsewhere when an option has reached its limit.
  • Randomization changes the page order. Jumps follow the order the respondent sees.