#if, #elseif and #else
#if, #elseif and #else statements can be used in templates to define "if this, then that" type scenarios.
Data markers are used within these to produce conditional content based on information saved to the matter or contact.
#if
Can be used to output a statement based on information saved to a data marker.
Example | Output |
| Acts in a true or false manner. If the data marker If the data marker is empty or set to the words "false" or "no" , the statement will be ignored. |
Within #if statements, the following conditions are treated as true:
- The word "true"
- The word "yes"
- A string of 1 or more characters, except the words "false" or "no"
- A list containing at least 1 item, when using the #foreach helper
- The value "0"
The following conditions are treated as false:
- The word "false"
- The word "no"
- An empty value
- A list with no items, when using the #foreach helper
Operators
The following operators can be used in conjunction with an #if statement:
Operator | Use Case | Example | Output |
= | To evaluate whether two values are equal to one another. The second value can be a text string surrounded by double quotation marks or another data marker. |
| If the data marker If the data marker is set to any other value, the statement won't be outputted. |
and | To evaluate the response of more than one data marker. The response will be outputted if all conditions have been met. |
| If the data markers If the data markers are set to false, the statement won't be outputted. |
or | To evaluate the response of more than one data marker. The response will be outputted if just one of the conditions have been met. |
| If the data marker If both data markers are set to false, the statement won't be outputted. |
not | To evaluate whether a data marker's response is set to false. |
| If the data marker If the data marker is set to true, the statement won't be outputted. |
!= | To evaluate whether two values are not equal to one another. The second value can be a text string surrounded by double quotation marks or another data marker. |
| If the data marker If the data marker is set to any other value, the statement will be outputted. |
contains | To evaluate whether multiple choice type data contains a specific set of answers. |
| If the data marker If the data marker contains "Contaminated Land" as an answer, the second statement will be outputted. If the data marker contains both "Flood" and "Contaminated Land" as an answer, both statements will be outputted. If the data marker contains neither, the statements will be ignored. |
> | To evaluate whether one value is greater than another. These values can be set as numbers, dates or data markers. If working with dates, these need to be formatted as a UTC ISO String. For example "yyyy-MM-ddTHH:mm:ssZ". Use the helper $now to compare values against the current date. |
| If the data marker If the data marker is less than 1,000,000, the statement won't be outputted. |
>= | To evaluate whether one value is greater than or equal to another. These values can be set as numbers, dates or data markers. If working with dates, these need to be formatted as a UTC ISO String. For example "yyyy-MM-ddTHH:mm:ssZ". Use the helper $now to compare values against the current date. |
| If the data marker If the data marker is less than 1,000,000, the statement won't be outputted. |
< | To evaluate whether one value is less than another. These values can be set as numbers, dates or data markers. If working with dates, these need to be formatted as a UTC ISO String. For example "yyyy-MM-ddTHH:mm:ssZ". Use the helper $now to compare values against the current date. |
| If the data marker If the data marker is more than 1,000,000, the statement won't be outputted. |
<= | To evaluate whether one value is less than or equal to another. These values can be set as numbers, dates or data markers. If working with dates, these need to be formatted as a UTC ISO String. For example "yyyy-MM-ddTHH:mm:ssZ". Use the helper $now to compare values against the current date. |
| If the data marker If the data marker is more than 1,000,000, the statement won't be outputted. |
Evaluation order
Operators are evaluated in the following order:
(...)
bracketsnot
>
>=
<
<=
contains
=
!=
and
or
#elseif
Can be used to add extra variables into the statement.
Example | Output |
| If the data marker If the data marker has "freehold" saved against it, the second statement will be outputted. If the data is anything other than "leasehold" or "freehold" the statements will be ignored. |
#else
Can be used to define an output if no other conditions have been met.
Example | Output |
| If the data marker If the data marker has "freehold" saved against it, the second statement will be outputted. If the data is anything other than "leasehold" or "freehold" the third statement will be outputted. |