You can configure a survey using logic rules to enhance its usability, streamline it, offer branching options, and perform background calculations for your users.
Considerations
- Designer tab vs. Logic tab: Not all logic rules are well-suited to be configured in the Designer tab. The Logic tab offers an easy-to-use interface that reduces the number of expressions that must be manually constructed in the logic rule.
Who can do this?
- Workplace administrators
- Site administrators
- Creators
Logic flows in a survey
Using logic flows, such as branching logic, allows you to create a user-friendly survey tailored to the user's needs based on their answers. The following sections offer a brief overview of the type of logic flows you can use in the survey.
Branching logic
Branching logic lets you design surveys that direct users along conditional paths based on their answers to questions. It allows the survey to skip questions, hide or show different sections, or finish the survey early.
For more information, see SurveyJS's Branching Logic article.
Skip logic
Skip logic lets you guide respondents through the survey based on their answers. It helps ensure they see only the most relevant questions, making the survey faster to complete and more tailored to their individual experience.
For more information on configuring skip logic workflows, see SurveyJS's Skip Logic article.
Display logic
Display logic lets you control which survey fields or sections are shown or hidden based on specific conditions. Rather than presenting every question or option upfront, it tailors the survey content in real time, adjusting to the user's responses and revealing only the information that's relevant to them.
For more information on configuring display logic workflows, see SurveyJS's Display Logic article.
Logic rules
Logic rules are the essential component of creating logic flows through the survey. They are IF/THEN statements that can be used to run actions if the conditions of the logic rule are met. For example:
IF - QuestionID - Logical Operation - THEN- Action
The image below visually represents this format on the Logic tab.
If you wanted to add a logic rule that would show question 2 if question 1's rating values were 4 or 5, it would look similar to: IF - question1 - EQUALS 4 - OR - EQUALS 5 - THEN - SHOW question2
More complex logic rules can be created using expressions. See the SurveyJS's Conditional Logic and Dynamic Texts and SurveyJS' Expression Syntax articles for supported placeholders and expressions.
Add a rule
Logic rules can be applied in the Logic tab to add multiple logic rules or in the Designer tab to add a rule to a specific question. Before adding logic rules, a survey must have questions in the Designer tab.
To add a rule in the Logic tab:
- On the Top Bar, select
Profile Menu, followed by Survey Manager.
- Select the title of your survey to open it. To create a new survey, see Add or edit a survey. Your survey must have questions in the Designer tab before you can continue this process.
- Select the Logic tab.
- Select Add New Rule.
- In the If/Then statement, choose the following:
- QuestionID: Choose any of the questions from the survey.
- Logical Operator: (Optional) Choose a different logical operator. See the Logical operators section below.
-
Add condition: (Optional) Select to add an additional condition to the statement, consisting of a QuestionID and a logical operator. If you do not need the additional condition, select
Delete beside the condition to remove it from the rule.
- Action: Choose an action to be taken if the rule's requirements are met. See the Actions section below.
- Add action: (Optional) Select to add an additional action to be taken if the requirements of the IF/Then statement are met.
- Once you have designed the rule to your requirement, select Done.
- In the top right corner of the survey editor, select Save to apply your changes.
To add a rule from the Designer tab:
- On the Top Bar, select
Profile Menu, followed by Survey Manager.
- Select the title of your survey to open it. To create a new survey, see Add or edit a survey. Your survey must have questions in the Designer tab before you can continue this process.
- Select the question to add a logic rule.
- In the right side panel, select Logic to expand the section.
- Locate the rule in one of the logic prompt boxes. See the Designer tab logic prompt boxes section below to identify which logic prompt box to edit. You can select
Edit to use the graphical interface to create a rule or use expressions to enter a rule manually. See the SurveyJS's Conditional Logic and Dynamic Texts and SurveyJS' Expression Syntax articles for supported placeholders and expressions.
- Manually edit the text of the rule. Not all logic rules can be edited from this screen; some must be edited from the Logic tab.
- In the top right corner of the survey editor, select Save to apply your changes.
Logical operators
The following logical operators are available to be applied to logic rules:
- Empty
- Not empty
- Equals
- Does not equal
- Any of
- Greater than
- Less than
- Greater than or equal to
- Less than or equal to
Actions
The following actions are available to be applied to logic rules:
| Question / Panel Type | Description |
|---|---|
| Show (hide) question | Select a question to show or hide it in the survey. |
| Enable (disable) question | Select a question to turn it on or off in the survey. |
| Make question required | Select a question to be required in the survey. |
| Reset question value | Select a question to reset the question's values in the survey. |
| Set question value | Select to set the question's value to another value or an expression. |
| Complete survey | Select to trigger survey completion. |
| Set answer | Select to set a specified answer to the selected question. |
| Copy answer | Select to copy an answer from the selected question to a target question. |
| Skip to question | Select a question to have the user redirected to the question in the survey. |
| Run expression | Select to run a custom expression on the selected question. |
| Set "Survey Complete" page markup | Set to specific custom HTML markup for the Survey Complete page. |
Designer tab logic prompt boxes
| Logic Prompt Box | Description |
|---|---|
| Visible if | Enter a logic rule to make the question visible to the user. |
| Editable if | Enter a logic rule to allow the question to be used by the user. |
| Required if | Enter a logic rule to require the question to be filled out. |
| Default value expression | Enter a logic rule to enter a default value at the start of the survey or if no response is given. |
| Reset value if | Enter a logic rule to reset the selected value of the question. |
| Set value if | Enter a logic rule to set a value for the question. |
| Set value expression | Enter a logic rule that will dynamically calculate and possibly overwrite a value, including default values. |
| Hide the question if it contains no choices | Select to hide a question if it contains no choices. |
| Choices are visible if | Enter a logic rule to hide a question's choices. |
| Choices are selectable if | Enter a logic rule to prevent a question's choices from being selectable by a user. |
Edit a rule
To edit a rule from the Logic tab:
- On the Top Bar, select
Profile Menu, followed by Survey Manager.
- Select the title of your survey to open it.
- Select the Logic tab.
- Select the rule to be edited.
- Make any modifications to the rules required and select Done.
- In the top right corner of the survey editor, select Save to apply your changes.
To edit a rule from the Designer tab:
- On the Top Bar, select
Profile Menu, followed by Survey Manager.
- Select the title of your survey to open it.
- Select the question.
- In the right side panel, select Logic to expand the section.
- Locate the rule in one of the logic prompt boxes. See the Designer tab logic prompt boxes section above to identify which logic prompt box to edit. Manually edit the text of the rule. Not all logic rules can be edited from this screen; some must be edited from the Logic tab.
- In the top right corner of the survey editor, select Save to apply your changes.
Delete a rule
To delete a rule from the Logic tab:
- On the Top Bar, select
Profile Menu, followed by Survey Manager.
- Select the title of your survey to open it.
- Select the Logic tab.
- Hover over the logic rule to be deleted and select
Delete.
- In the top right corner of the survey editor, select Save to apply your changes.
To delete a rule from the Designer tab:
- On the Top Bar, select
Profile Menu, followed by Survey Manager.
- Select the title of your survey to open it.
- Select the question.
- In the right side panel, select Logic to expand the section.
- Locate the rule in one of the logic prompt boxes. Manually remove the text of the rule or select
Clear to remove all rules from the box. Not all logic rules can be removed from this screen; some must be removed from the Logic tab.
- In the top right corner of the survey editor, select Save to apply your changes.