Conditional logic can be implemented to display and hide content in the Word document output depending on how questions are answered.
IF Conditional Statements
Example 1:
Question: Will the employee be subject to a non-compete clause?
ID: hasNonCompete
Answer Options: Yes, No
If there is a clause in the agreement that should only appear if the answer to the question is "Yes", it would be encoded the following way:
{#hasNonCompete == "Yes"}The employee will not, without the prior written consent of the employer, at any time for a period of 12 months, compete with the employer.{/}
Notice that the opening of the tag includes a "#" followed by the condition with no space in between the # and the ID. The tag is closed with a {/}.
If the answer to the question is "Yes", the clause will be generated. If the answer to the question is "No", the clause will be omitted from the output document.
Example 2:
Question: Do you own a business?
ID: ownsABusiness
Answer Options: Yes, No
Question: What type of business do you own?
ID: businessType
If there is additional information that should be displayed if the response to this question is "Yes", encode it the following way:
{#ownsABusiness =="Yes"}Business Name: {businessName}
Business Type: {businessType}{/}
This will output the name of the business and type of business as collected from the Questionnaire.
These questions would also be ideal candidates for the Visibility Conditions.
Learn more about Visibility Conditions in Questionnaires.
IF NOT Conditional Statements
If you are looking for your document to display an output if the dropdown answer is equal to everything except one option, you can use the IF NOT conditional statement type.
- Corporation
- Partnership
- Sole Proprietor
AND Conditional Statements
Here is an example:
Questions:
Do you Own a Business? Yes/No
What type of business are you? Sole Proprietor/Partnership/Corporation
In this scenario, we only want to output information if the answers are both "Yes" and "Partnership".
{#ownsABusiness == “Yes” && businessType == “Partnership”} Name of Partner Here {/}
OR Conditional Statements
Here is an example:
Questions:
What type of business are you? Sole Proprietor/Partnership/Corporation
In this scenario, we only want to output information if the answer is either "Partnership" or "Corporation".
{#businessType == “Partnership” businessType == “Corporation”} Shareholder Information {/}
Important Tips
All conditional statements being with a "#" in the first tag of the statement and end with a {/}.
When specifying the answer, it must be typed EXACTLY the same as it is represented in the questionnaire.
For example, if the answer in the questionnaire is "Yes" with a capital Y, you must include that capital letter in the code tag.
You can put a conditional statement inside another conditional statement (nesting conditionals). Ensure you have all of the tags starting with the "#' and ending with the {/}.
See some conditional statement examples in action in our video below: