Overview
The Style Expression field is available in Document Customization → Custom Fields (and field overrides) for computed fields, custom fields, and standard field overrides. It allows you to apply conditional visual formatting - such as background color - to a field displayed in a document or grid view, based on field values in the underlying record.
Note: Style expressions affect the UI display only. Reports use separate scripts and are not covered by this feature.
Where to Find It
Navigate to: System - Document Customizations - Document ID - Custom Fields
In the Custom Fields grid, locate the Style Expression column. This is a free-form text entry field - you must enter expressions using the correct syntax described below.
Syntax
Style expressions use the IIF (inline-if) function. In current versions, the pipe character (|) is required as the delimiter between parts of the expression:
IIF( condition | true_style | false_style )
| Part | Description |
|---|---|
| condition | A logical expression evaluated against the record (e.g., wo_type_no=47) |
| true_style | The style applied when the condition evaluates to true |
| false_style | The style applied when the condition evaluates to false |
Important: In newer versions of Xytech (v10+), the pipe character (|) must be used as the delimiter - not commas. Comma-separated syntax from older versions will not work correctly on newer releases. Additionally, a pipeline must be configured for Style Expressions to function in current versions. If expressions are not producing results, confirm that the appropriate pipeline is in place.
Supported Style Properties
| Property | Example | Description |
|---|---|---|
| bgcolor | bgcolor:Red | Sets the background color of the cell |
Colors can be specified using a named color (e.g., Red, Green, Yellow) or a hex color code (e.g., #FF0000, #F7FF00, #0FFF00).
Components of a Style Expression
A style expression can include any combination of the following:
IIf Function
Returns one of two values depending on whether a condition is true or false. Can be nested for multiple conditions.
Syntax:
IIf( expr | truepart | falsepart )
Fields
Reference fields on the current row using the fully resolved database column name shown in Document Customizations (e.g., wo_type_no, TRX_expression_91). Operations directly on fields are not permitted.
Duration Functions
Used when working with DURATION-type expressions. Duration values are stored in ticks, so the following helper functions are provided to convert human-readable units:
- TicksFromSeconds( value )
- TicksFromHours( value )
- TicksFromDays( value )
Constants
Static numeric or string values used in conditions.
Examples
Simple Condition - Color by Work Order Type
IIF(wo_type_no=47 | bgcolor:Red | bgcolor:Green)
If the work order type is 47, the cell background turns red; otherwise it turns green.
Nested Condition - Color by Duration (Days)
IIF(TRX_expression_91<=ticksFromDays(10) | IIF(TRX_expression_91<=ticksFromDays(5) | bgcolor:Red | bgcolor:Yellow) | bgcolor:Green)
- 5 days or fewer → Red
- 6–10 days → Yellow
- More than 10 days → Green
Nested Condition - Color by Duration (Hours)
IIF(TRX_expression_91>ticksFromHours(10) | bgcolor:Green | IIF(TRX_expression_91>ticksFromHours(5) | bgcolor:Yellow | bgcolor:Red))
- More than 10 hours → Green
- 6–10 hours → Yellow
- 5 hours or fewer → Red
Troubleshooting
Expression Has No Effect / Cells Show Grey
Confirm that a pipeline is configured in your environment — this is required for Style Expressions to work in current versions.
Expression Worked Previously but Stopped After an Upgrade
Check that your expression uses the pipe (|) delimiter instead of commas. Older comma-separated syntax is not supported in current versions.
Static Color Works but IIF Does Not
This is typically a pipeline configuration issue. A static value like bgcolor:#0FFF00 will render correctly without a pipeline, but conditional IIF expressions require one.
Syntax Errors / No Color Rendered
- Ensure delimiters are pipe characters (|), not commas
- Verify the database column name matches exactly what is shown in the Document Customizations fields grid
- Confirm color names are spelled correctly or that hex codes are valid