- 27 Sep 2023
- 2 Minutes to read
- Print
- PDF
Administrator: Attribute Constraints
- Updated on 27 Sep 2023
- 2 Minutes to read
- Print
- PDF
1. What are Attribute Constraints?
Attribute constraints can be used to control when attributes appear or the values that might be available in a List.
For example, you may only wish to show the result of a review when a status attribute has actually been set to Reviewed. Likewise, you may wish to only have certain values available in a List based on other attribute choices.
In this way, you can build up so called dependent attributes.
2. How are Constraints defined?
Constraints are defined as a logical expression, using boolean operators and variables based on attribute status. For example, to make the attribute Review Result only appear when the Status attribute is Reviewed, you might set this constraint:
$Status = "Reviewed"
Ultimately, an attribute constraint should resolve as True if it should be shown and False if it should be hidden.
3. How constraints are attached to attributes
In most cases, attributes are defined at the attachment point. This means you can reuse the same attribute in different ways on jobs, folders or files.
However, if you wish to constrain the values in a List attribute, the constrains must be defined globally.
4. Components of a Constraint
4.1. Attributes
While not strictly necessary, an attribute constraint should be used to compare against other attributes. EG: Only show attribute A when Attribute B is equal to some value. Note that attributes in a constraint don't need to come from the same entity - if you are constraining attribute visibility for a File, you can query against attribute values on the Job or Folder. Likewise, Sub-Jobs can query against the attributes on the parent job.
4.2. Comparison Operators
Currently, Attribute Constraints only support direct matches using the = operator
4.3. Boolean Operations
You can use operations with the Boolean Operations AND and OR This allows you to make conditions with multiple comparisons against one or more attributes.
For example:
$Status = "Reviewed" OR $Status = "Completed"
This means, when the value of Status is Reviewed or Completed
Alternatively, you can use brackets to perform more complex constraint queries.
For example:
$Type = "Quote" and ($Status = "Pending" OR $Status = "In Progress")
This means, visible when the value of Type is quote and the value of Status is either Pending or In Progress
4.4. Functions
Functions can also be used to help evaluate if an attribute or value should be displayed.
Constraint functions can't be performed on attributes with spaces in their names. For example Exists($optional contact) will not work, but Exists($optional_contact) will.
The following functions are available.
4.5. Exists
Description: Looks to see if the value of the attribute exists as the name of another attribute. For example if you have a list attribute called work_state with: in progress, review and complete you could set another attribute with a constraint of Exists($work_state). This attribute would only become visible if work_state had one of those values selected AND there was another attribute on the entity called in progress, review or complete.
Usage: Exists($Attribute)
4.6. HasValue
Description: Determines if an attribute exists and has a value. This one is more simple. Using the above example, if work_state had a value selected the attribute with the constraint HasValue($work_state) would become visible.
Usage: HasValue($Attribute)