Conditions and conditional styles
Hide elements and change styles from data. Data and expressions in the DocStudio designer user guide.
Show an element only sometimes
- Select the element.
- In Conditions click Add condition.
- Build an expression that is true when the element should be shown, for example
gt(daysOverdue, 0).
When the condition is false the element is not drawn at all. In Layers it shows a small mark and the label "hidden by condition". The element stays in the template.
Truthiness: false, 0, empty text, null, a missing value and an empty list are false. Everything else is true.
Change the style from data
In Conditions, Conditional styles, click Add rule. A rule has a condition and a style. When the condition is true the style properties apply on top of the normal style. Use Add style property to choose which properties the rule sets.
Example: show a late invoice amount in red. Condition gt(daysOverdue, 30), style color: #b42318.
Remove
Use Remove condition or Remove rule.
Group with a section
Put several elements in a section and give the section the condition to hide them all together.
Limits
- A condition decides visibility only. It does not remove the element from the template.
- A missing value in a condition is false and no policy warning is raised.
- Up to 32 conditional style rules per element.