Skip to main content

Conditional Logic

What Is Conditional Logic?

Conditional logic makes a form respond to the answers it receives. A follow-up question appears only after the answer that makes it relevant, a page of approval questions is shown only for expensive requests, a field becomes required only in the situation that calls for it, and a choice list offers only the options that apply to the respondent.

Every respondent gets a form that fits their situation: they don't scroll past questions that don't concern them, they aren't asked for details that don't apply, and they're less likely to give up halfway. You get cleaner data — no "N/A" answers to filter out — and you can serve several scenarios with one form instead of maintaining a separate form for each.

In Endatix Hub, you add conditional logic in the Form Builder, without writing code: create rules in the Logic tab, or set conditions on a question, panel, page, or choice in the Property Grid.

How It Works

  • A condition is a yes-or-no question about the answers. It refers to questions by name, such as {request_type} = 'new_hire' — "is the answer to request_type equal to new_hire?"
  • Each condition controls one setting. For example, Make the question visible if shows the question while its condition is true and hides it while the condition is false.
  • The form updates as the respondent answers. Conditions are re-checked the moment an answer they refer to changes, and their effect is reversed as soon as the condition stops being true.
  • The Logic tab and the Property Grid show the same settings. A rule you create in the Logic tab is saved as the element's condition, and a condition you type in the Property Grid appears as a rule in the Logic tab.
  • Conditions compare stored values. A choice is compared by its value (new_hire), not the text respondents see, and a Yes/No question by true or false. Text comparisons ignore capitalization.

What You Can Control

Questions

Select a question and open the Conditions category in the Property Grid.

SettingWhat happens while the condition is trueLogic tab action
Make the question visible ifThe question is shown. While it's hidden, it isn't validated, so a hidden required question doesn't block the respondent.Show/hide question
Disable the read-only mode ifThe question can be edited. Until then, it's shown read-only, and any default answer it has is still saved.Enable/disable question
Make the question required ifThe question must be answered before the respondent can continue.Make question required
Reset value ifWhen the condition becomes true, the answer is cleared, or returned to the question's default value if it has one.Reset question value
Set value if and Set value expressionWhen the condition becomes true, the answer is set to the result of Set value expression. Without a Set value if condition, the expression recalculates the answer whenever a value it uses changes.Set question value
Default value expressionNot a condition: calculates the answer the question starts with. The respondent can change it.

Choices

SettingWhereWhat happens while the condition is true
Make the option visible ifChoice Options → a choice's Show DetailsThe choice is offered.
Make the option selectable ifChoice Options → a choice's Show DetailsThe choice can be selected. Until then, it's shown but disabled.
Make choices visible if, Make choices selectable ifThe question's Conditions categoryOne condition checked for every choice, where {item} stands for the choice's value — for example, {item} != 'phone' or {department} = 'sales'.
Hide the question if it has no choicesThe question's Conditions categoryHides the question when conditions leave it without any choice to offer.

If a choice the respondent has already selected is hidden, it's removed from their answer. Choice conditions aren't listed in the Logic tab. To build a choice list from earlier answers instead, see Carry Forward.

Panels and Pages

SettingWhat happens while the condition is trueLogic tab action
Make the panel visible if, Make the page visible ifThe panel or page is shown. Hidden pages are skipped when the respondent clicks Next, and their questions aren't validated.Show/hide panel, Show/hide page
Disable the read-only mode ifThe questions in the panel or page can be edited. Until then, they're all read-only.Enable/disable panel, Enable/disable page
Make the panel required if, Make the page required ifAt least one question in the panel or page must be answered.Make panel required, Make page required
Make an individual entry visible ifFor a Dynamic Panel: shows only the entries that match, using {panel.question_name}. See Question Loops.

Matrices

  • Make rows visible if and Make columns visible if — in a matrix question's Conditions category, one condition checked for every row or column, with {item} standing for its value.
  • Make the row visible if and Make the row editable if — on an individual row.
  • Make the column visible if, Disable the read-only mode if, and Make the column required if — on a column of a Multi-Select Matrix or Dynamic Matrix. In the Logic tab, these are the Show/hide column, Enable/disable column, Make column required, Reset column value, and Set column value actions. Use {row.column_name} to refer to another cell in the same row.

Form Flow and Results

Conditions also drive the features described in their own articles:

  • Triggers — end the form, skip ahead, or fill in answers when a condition is met.
  • Thank You Page — show a different message or redirect to a different page depending on the answers.
  • Validation — accept an answer only when an expression is true.
  • Custom Variables — calculate values, such as totals or scores, to use in other conditions.

Example: An IT Equipment Request Form

An IT team uses one form for three kinds of requests: equipment for a new hire, a replacement, or a repair. Conditional logic makes each respondent see only the questions for their request:

What should happenSettingCondition
Ask for the new hire's name only for new hiresnew_hire_nameMake the question visible if{request_type} = 'new_hire'
Ask which devices are needed, except for repairsdevicesMake the question visible if{request_type} anyof ['new_hire', 'replacement']
Ask for a description of the problem only for repairsissue_descriptionMake the question visible if{request_type} = 'repair'
Offer a mobile phone only to the Sales departmentdevicesMobile phoneMake the option visible if{department} = 'sales'
Require a reason for urgent requestsurgency_reasonMake the question required if{is_urgent} = true
Keep the head office as the delivery address unless the respondent chooses another onedelivery_addressDisable the read-only mode if{ship_elsewhere} = true
Ask for manager approval for laptops and phonesManager approval page → Make the page visible if{devices} anyof ['laptop', 'phone']

1. Show a Question for New Hires in the Logic Tab

Open the form's Logic tab and click Add New Rule. Then:

  1. In the If row, select the request_type question with the Equals operator, and select Equipment for a new hire.
  2. In the then row, open Select action..., choose Show/hide question, and select new_hire_name.
  3. Click Done.
Logic tab rule If 'request_type' == 'new_hire' with the condition request_type Equals Equipment for a new hire and the Show/hide question action for new_hire_name. An arrow points at the new_hire_name target.Logic tab rule If 'request_type' == 'new_hire' with the condition request_type Equals Equipment for a new hire and the Show/hide question action for new_hire_name. An arrow points at the new_hire_name target.

To combine conditions, click Add Condition and choose and or or for the new row. To type the condition instead, click Manual Entry at the top of the tab while the rule is open. Add Action attaches more actions to the same condition.

Add the other rules from the table the same way. The Logic tab lists them all, each summarized in a sentence:

Logic tab listing six rules: make page approval_page visible, make questions new_hire_name, devices, and issue_description visible, make question urgency_reason required, and make question delivery_address enable, followed by the Add New Rule button.Logic tab listing six rules: make page approval_page visible, make questions new_hire_name, devices, and issue_description visible, make question urgency_reason required, and make question delivery_address enable, followed by the Add New Rule button.

Click a rule to edit it. On a form with many rules, use All Questions and All Action Types at the top of the tab to show only the rules for one question or one kind of action.

2. Review a Question's Conditions in the Property Grid

Switch to the Designer tab, select the New hire's full name question, and click the Conditions icon in the category bar on the right of the Property Grid. The rule from step 1 is shown in Make the question visible if:

Property Grid Conditions category for the new_hire_name question, with Make the question visible if set to {request_type} = 'new_hire', followed by the empty Disable the read-only mode if, Make the question required if, Default value expression, Reset value if, Set value if, and Set value expression fields. An arrow points at the Conditions icon.Property Grid Conditions category for the new_hire_name question, with Make the question visible if set to {request_type} = 'new_hire', followed by the empty Disable the read-only mode if, Make the question required if, Default value expression, Reset value if, Set value if, and Set value expression fields. An arrow points at the Conditions icon.

You can type a condition directly into any of these fields, or click the magic wand icon to build it with the condition editor — the same If row as in the Logic tab. Click the eraser icon to remove a condition.

Condition editor for Make the question visible if, with request_type Equals and Equipment for a new hire selected, an Add Condition button, and Cancel and Apply buttons.Condition editor for Make the question visible if, with request_type Equals and Equipment for a new hire selected, an Add Condition button, and Cancel and Apply buttons.

3. Offer an Option Only to One Department

Choice conditions are set on the choice itself. Select the Which devices do you need? question, open the Choice Options category, and click Show Details (pencil icon) next to Mobile phone. Set Make the option visible if to {department} = 'sales':

Property Grid Choice Options category for the devices question, with the phone choice expanded and Make the option visible if set to {department} = 'sales'. An arrow points at the Choice Options icon.Property Grid Choice Options category for the devices question, with the phone choice expanded and Make the option visible if set to {department} = 'sales'. An arrow points at the Choice Options icon.

4. Test the Logic

Open the Preview tab and answer the questions in different ways. To check your conditions without filling out the form, click Show invisible elements (eye icon) in the Preview toolbar: hidden questions are then shown too, so you can see what's there.

In the published form, a respondent from Sales who requests equipment for a new hire sees the name question and the Mobile phone option — and none of the repair questions:

Published IT Equipment Request form with Equipment for a new hire selected, the New hire's full name question shown with an arrow pointing at it, Sales selected as the department, and Mobile phone offered among the devices

Writing Conditions

The condition editor offers the operators that fit the selected question. When you type a condition, use the operator in the right column:

Operator in the editorIn a typed conditionExample
Equals, Does not equal=, <>{request_type} = 'repair'
Greater than, Less than, Greater than or equal to, Less than or equal to>, <, >=, <={quantity} >= 5
Empty, Not emptyempty, notempty{issue_description} notempty
Contains, Does not containcontains, notcontains{devices} contains 'laptop'
Any of, None of, All ofanyof, noneof, allof{devices} anyof ['laptop', 'phone']
and, orand, or, and parentheses for grouping{is_urgent} = true and ({devices} contains 'laptop')

Typed conditions can also use functions, such as today() and age(), and custom variables. See Logic Expressions for the full reference.

Hidden Questions and Their Answers

When a question is hidden after it's been answered — for example, the respondent types a new hire's name and then switches to A repair — the answer is kept while the form is being filled out, so it comes back if the question is shown again. When the form is completed, answers to hidden questions are removed from the submission.

To change when that happens, click an empty area of the design surface, open the survey's Data category, and set Clear hidden question values:

Property Grid Data category for the survey with Clear hidden question values set to Upon survey completion. An arrow points at the Data icon.Property Grid Data category for the survey with Clear hidden question values set to Upon survey completion. An arrow points at the Data icon.
OptionAnswers to hidden questions are removed
Upon survey completion (default)When the form is completed.
When question gets hiddenAs soon as the question is hidden by its own condition.
When question or its panel/page gets hiddenAs soon as the question, or the panel or page it's on, is hidden.
NeverNever — they're saved with the submission.

A question can override this setting with its own Clear hidden question values in its Data category. Its default, Inherit, uses the survey's setting.

Incomplete submissions keep hidden answers

Hub saves a respondent's progress while they fill out the form. With the default setting, an incomplete submission can still contain answers to questions that are currently hidden; they're removed when the respondent completes the form.

Important Considerations

  • Refer to questions that come earlier. A condition that depends on a question the respondent hasn't answered yet is evaluated with an empty answer, so base the logic for a page on the pages before it.
  • A misspelled name doesn't produce an error. A condition that refers to a name no question uses is simply false, so a question it shows never appears. The Logic tab lists such a rule without a warning, and the Diagnostics tab doesn't flag it — check the names if something never appears.
  • Renaming updates conditions. Conditions follow a question when you change its Question name, and a choice when you change its Value in the Property Grid. Changing a choice's text doesn't affect conditions, because they compare values.
  • Hidden and read-only aren't the same. A read-only question is still visible and its answer is saved; a hidden question's answer is removed when the form is completed.
  • Design mode shows everything. The Designer tab always shows all questions, whatever their conditions. Use the Preview tab to see the logic in action.

Technical Reference (JSON Schema)

Conditions are stored as properties of the element they control. The example form looks like this in the JSON Editor:

{
"title": "IT Equipment Request",
"pages": [
{
"name": "request_page",
"title": "Request details",
"elements": [
{
"type": "radiogroup",
"name": "request_type",
"title": "What do you need?",
"isRequired": true,
"choices": [
{ "value": "new_hire", "text": "Equipment for a new hire" },
{ "value": "replacement", "text": "A replacement for my equipment" },
{ "value": "repair", "text": "A repair" }
]
},
{
"type": "text",
"name": "new_hire_name",
"visibleIf": "{request_type} = 'new_hire'",
"title": "New hire's full name",
"isRequired": true
},
{
"type": "dropdown",
"name": "department",
"title": "Department",
"isRequired": true,
"choices": [
{ "value": "sales", "text": "Sales" },
{ "value": "engineering", "text": "Engineering" },
{ "value": "finance", "text": "Finance" }
]
},
{
"type": "checkbox",
"name": "devices",
"visibleIf": "{request_type} anyof ['new_hire', 'replacement']",
"title": "Which devices do you need?",
"isRequired": true,
"choices": [
{ "value": "laptop", "text": "Laptop" },
{ "value": "monitor", "text": "Monitor" },
{ "value": "headset", "text": "Headset" },
{ "value": "phone", "text": "Mobile phone", "visibleIf": "{department} = 'sales'" }
]
},
{
"type": "comment",
"name": "issue_description",
"visibleIf": "{request_type} = 'repair'",
"title": "Describe the problem",
"isRequired": true
},
{ "type": "boolean", "name": "is_urgent", "title": "Is this request urgent?" },
{
"type": "comment",
"name": "urgency_reason",
"title": "Why is it urgent?",
"description": "Required for urgent requests.",
"requiredIf": "{is_urgent} = true"
},
{
"type": "panel",
"name": "delivery",
"title": "Delivery",
"elements": [
{ "type": "boolean", "name": "ship_elsewhere", "title": "Ship to an address other than the head office?" },
{
"type": "text",
"name": "delivery_address",
"title": "Delivery address",
"defaultValue": "Head office, 12 Harbor Street",
"enableIf": "{ship_elsewhere} = true"
}
]
}
]
},
{
"name": "approval_page",
"title": "Manager approval",
"visibleIf": "{devices} anyof ['laptop', 'phone']",
"elements": [
{ "type": "text", "name": "manager_email", "title": "Manager's email address", "inputType": "email", "isRequired": true }
]
}
]
}

Condition Properties

PropertyAvailable onProperty Grid setting
visibleIfQuestions, panels, pages, choices, matrix rows and columnsMake the question / panel / page / option / row / column visible if
enableIfQuestions, panels, pages, choices, matrix rows and columnsDisable the read-only mode if, Make the option selectable if, Make the row editable if
requiredIfQuestions, panels, pages, matrix columnsMake the question / panel / page / column required if
resetValueIfQuestionsReset value if
setValueIf, setValueExpressionQuestionsSet value if, Set value expression
defaultValueExpressionQuestionsDefault value expression
choicesVisibleIf, choicesEnableIfChoice questionsMake choices visible if, Make choices selectable if
hideIfChoicesEmptyChoice questionsHide the question if it has no choices
rowsVisibleIf, columnsVisibleIfMatrix questionsMake rows visible if, Make columns visible if
templateVisibleIfDynamic PanelsMake an individual entry visible if
clearInvisibleValuesSurveyClear hidden question values: "onComplete" (default), "onHidden", "onHiddenContainer", or "none"
clearIfInvisibleQuestionsThe question's own Clear hidden question values: "default" (Inherit) uses the survey setting