The visibleIf attribute controls whether a form field or a section displays. The field or section displays only when its condition is met. A condition checks the value of another field on the same form.
Before you start
- You set visibleIf in the attributes of a field or section, in the form JSON in Form Builder.
- A condition refers to another field by its field name, not by its title.
- When a condition is wrong, no error displays. The field stays hidden. Clio recommends that you test every condition with Preview in Form Builder.
How a condition matches a value
= is the only comparison operator. A condition is met only when the value matches exactly.
- Matching is case-sensitive.
Status=Opendoesn't matchopen. - The whole value must match.
Name=Foodoesn't matchFoo Bar. - Extra spaces prevent a match, including a space at the end of the value.
- Text values work the same way as other values.
TextField1=foo barmatches onlyfoo bar. - Don't put spaces around
=.Status = Opennever matches. - Don't put quotation marks around a value. Quotation marks become part of the value, so
Status='Open'matches only'Open'. - In a field's condition, the field name isn't case-sensitive. In a section's condition, it is. See visibleIf on sections.
- For an option set picker, the value is the ID of the option set value, not its name.
Housing=500000524works, butHousing=Tenantnever matches. - For a multi-select option set picker, the condition is met when the ID is one of the selected values.
Find the ID of an option set value
- Navigate to Admin > Data > Option Sets.
- Select the option set.
- Select Manage Values.
The ID column displays the ID of each option set value.
Option set value IDs belong to the environment. Move the form and its option sets between environments with Import/Export, which keeps the IDs. If an option set was created by hand in each environment, check the IDs in every environment. A condition copied from another environment might never match.
Operators that aren't supported
!=, >, >=, < and <= aren't supported. If you use one of these operators, the condition is never met and the field never displays. No error displays.
Write a simple condition
A simple condition names a field and a value:
"visibleIf": "field=true"To combine conditions as AND, separate them with a comma. The field displays only when both conditions are met:
"visibleIf": "field=true,field2=1234"List the same field more than once
If the same field appears more than once, the field displays when any of the listed values match. A comma between different fields means AND. A comma between conditions on the same field means OR.
"visibleIf": "Status=Open,Status=Pending"This condition displays the field when Status is Open or Pending.
Don't use this pattern on a section. See visibleIf on sections.
Write an expression
Use an expression when you need OR between different fields, or nested conditions:
"visibleIf": ":([TestField1=aruba] OR [TestField2=bob]) AND [toggleField=true]"An expression must follow these rules:
- The first character must be
:. Without the:, the condition is never met. - Put each condition inside square brackets, for example
[SomePicker=1234]. - AND and OR can be uppercase or lowercase. They must have a space on each side, for example
[Field1=a] OR [Field2=b]. - Use round brackets to group conditions. You can nest groups to any level. Every opening bracket must have a closing bracket.
If you leave out the spaces around OR, for example [Field1=a]OR[Field2=b], the expression behaves as AND. No error displays.
Combine AND and OR
Without round brackets, Clio Operate evaluates AND and OR from left to right. :[A=1] OR [B=1] AND [C=1] means :([A=1] OR [B=1]) AND [C=1]. Clio recommends that you always use round brackets when you combine AND and OR.
Use the same field in more than one condition
If the same field appears in more than one set of square brackets, each condition matches any of the values listed for that field. The match happens even when the conditions are joined by AND. For example, :[Status=Open] AND [Status=Pending] displays the field when Status is Open or Pending.
Check whether a field has a value
visibleIf has no check for "has a value" or "is empty".
- A field name on its own, such as
Statusor:[Status], doesn't check for a value. The field always displays, provided that the field named in the condition displays. -
Status=matches only a value that was entered and then deleted. It doesn't match a field that has never had a value, so don't use it as an "is empty" check.
If the field named in the condition has a fixed set of values, such as an option set picker or a toggle, list each value that counts as "has a value". For an option set picker, list the ID of each option set value:
"visibleIf": "Priority=500000101,Priority=500000102,Priority=500000103"For a free-text field, there is no way to check for a value.
Hidden controlling fields
If the field named in a condition is hidden, the field that depends on it is hidden too. This rule applies even when the hidden field still holds a matching value.
You can use this rule to build a chain. For example, Field B depends on Field A, and Field C depends on Field B. When Field A changes so that Field B is hidden, Field C is hidden as well.
visibleIf on sections
A section's visibleIf supports simple conditions only.
- A comma between conditions means AND.
- Expressions that start with
:aren't supported. The section never appears, and no error is displayed. - The field name must match the field's name exactly, including uppercase and lowercase letters.
- A section's condition can refer to a field outside the section, or to a field in another section.
Don't list the same field more than once in a section's visibleIf. If you do, the whole form fails to render, and an error displays: "An error occurred during a call to the server: 'An item with the same key has already been added.'"
Fields inside a section
- A field inside a section can use simple conditions and expressions that refer to other fields in the same section.
- A field inside a section can't refer to a field outside the section. The field never displays. Put the condition on the section instead.
Common mistakes
| Condition | What happens | What to do |
|---|---|---|
Status!=Closed |
The field never displays. | List the values that should display the field. |
Name>'' |
The field never displays. | There is no check for "has a value". See Check whether a field has a value. |
Status = Open |
The field never displays. | Remove the spaces around =. |
Status='Open' |
Matches only the text 'Open', including the quotation marks. |
Remove the quotation marks. |
Housing=Tenant on an option set picker |
The field never displays. | Use the ID of the option set value, for example Housing=500000524. |
[A=1] OR [B=1] |
The field never displays. | Add : at the start of the expression. |
:[A=1]OR[B=1] |
Behaves as AND. | Add a space on each side of OR. |
Status=Open,Status=Closed on a section |
The whole form fails to render. | Don't repeat the field in a section's condition. |