Visibility Condition
This feature uses MariaDB syntax |
Note: Visibility Conditions take effect when the page is loaded. They will not run dynamically if the condition is based on changing the value of a field that is on the page. If you wish to change the visibility of fields dynamically, you should use the Show/Hide Header procedure.
Basic Condition Syntax
Visibility works by determining the truth of a given condition. For example: the field only shows for someone in the Reviewer role. In that case, the condition syntax would look like this:
@me.inRole(Reviewer)@
If the condition is true--that is, the user viewing the page does have the Reviewer role--then the field is displayed.
This can also work with a negative: the field is to be hidden from a Reviewer.
!@me.inRole(Reviewer)@
Note: because the statement must be true, the above syntax is actually looking to display the field to anyone NOT in the Reviewer role.
More Examples
Condition | Syntax |
Field is only visible if Status is either Draft or Open | "@status@" in ('Draft','Open') |
Field is only visible when it contains a value | "@fieldname.length@"*1>0 |
Field is visible if the type is NOT "Contract" | "@Type@"!="Contract" |
Field is only visible after February 6, 2015 | "@date(currentdate)@">"2015-02-06" |
Field is only visible if Start Date is on or after May 1, 2009* | "@fullstartdate@" >= "2009-05-01" |
Field is only visible if the value of Date Initiated is on or after 2014-01-31 | "@Date Initiated@" >= "2014-01-31" |
- IMPORTANT: for a visibility condition based on the startdate or enddate:
- Use '@fullstartdate@' rather than '@startdate@'
- Use '@fullenddate@' rather than '@enddate@'.
* This will format the stored date as yyyy-mm-dd so it can be compared using < and >. "@fullstartdate@" >= "2009-05-01"
Multiple Conditions
It is also possible to test multiple conditions:
- For an OR condition use two pipes (|)
"@status@" = "Closed" || "@me.fullname@"="Jane Doe"
The above field will be visible either if the status of the record is Closed, OR if the user viewing the record is named John Doe.
- For an AND condition use two ampersands (&)
"@status@" = "Closed" && "@me.fullname@"="John Doe"
The above field will be visible only if the status of the record is Closed AND the user viewing the record is named John Doe.
- You can also use a combination of these, using brackets to control the order of validation:
( "@status@" = "Closed" || "@status@" = "Cancelled") && ("@me.fullname@"="John Doe" || "@me.fullname@"="John Deer" || "@me.fullname@"="Dear John")
The above field will be visible only if the status of the record is either Closed OR Cancelled, AND the user is one of the 3 named users.
Contents
Note
- It is usually best practice to use double quotes (") around variables rather than single quotes ('). This is because single quotes are also apostrophes, so if the variable is processed and replaced with a term with an apostrophe it will close the statement and cause a server side error. (In principle the variable could also be replaced with text containing a double quote, also resulting in an error, but double quotes are less commonly stored.) (See SSEscape for additional information.)
See Also
- Visibility Condition
- Advanced Logic
- Determining the Application ID
- Determining the Category ID
- Determining the Company ID
- Determining the Custom Field ID
- Determining the Event ID
- Determining the File ID
- Determining the Folder ID
- Determining the Opportunity ID
- Determining the Report ID
- Determining the Role ID
- Determining the Root Company ID
- Determining the Status ID
- Determining the Type ID
- Determining the User ID
- Determining the Workflow ID
Visibility of Custom Fields can also be controlled using: