Skip to content

Display Expressions

Prerequisite

This page assumes you understand what a risk action is and how its JSON is structured. If you haven't already, read Anatomy of a Risk Action first — the action-level expressions covered here live inside the action config file.

Workbench has two distinct display expression systems that are easy to confuse. They use different syntax, evaluate against different data models, and are used in different contexts. Understanding the difference is essential.

The two systems at a glance

Action-level (displayCriteriaExpressions) Risk record (displayExpression)
Syntax JSONPath JavaScript
Evaluates against The risk evaluation context Response from GET /v2/risks/{id}
Used in Risk action JSON files Screen meta data, risk record config
Controls visibility of Entire risk actions Individual data fields
Result true = show, false = hide true = show, false = hide

Action-level: displayCriteriaExpressions

These are JSONPath expressions configured in risk action files. They control whether an entire risk action is visible to the user on the risk record.

Configuration

In the risk action JSON file:

{
  "code": "structured_quote",
  "displayCriteriaExpressions": [
    {
      "jsonPathExpression": "$.riskType",
      "operatorType": "EQUAL",
      "testValue": "NEW"
    }
  ]
}
Field Description
jsonPathExpression A JSONPath path into the risk evaluation context
operatorType One of EQUAL, NOT_EQUAL, IS_NULL, NOT_NULL, EQUAL_OR_NULL, NOT_EQUAL_OR_NULL. (GREATER_THAN, LESS_THAN, STARTSWITH exist in the enum but are not implemented for risk action display criteria — they are only honoured in pipeline configuration.)
testValue The value to compare against

Common patterns

Check the risk type:

{ "jsonPathExpression": "$.riskType", "operatorType": "EQUAL", "testValue": "NEW" }

Check a display flag:

{ "jsonPathExpression": "$.displayAllActions", "operatorType": "EQUAL", "testValue": "true" }

Check a risk value:

{ "jsonPathExpression": "$.riskValues[?(@.typeCode=='APPETITE_RESULT')].value", "operatorType": "EQUAL", "testValue": "APPROVED" }

Debugging action expressions

Set a breakpoint in RiskActionDisplayExpressionHelper.isFullDisplayExpressionPassed and reload the risk page. This lets you inspect the expression and the evaluation context at runtime to understand why an action is or isn't showing. See Remote Debugging for setup instructions.


Risk record: displayExpression and hideExpression

Two complementary expression fields are available on screen meta data elements and risk record config:

Field Behaviour
displayExpression Show the element when the expression returns true
hideExpression Hide the element when the expression returns true

Both evaluate JavaScript against the same data context. Use whichever reads more naturally for your condition. hideExpression is most common in screen meta data elements (action pop-up forms); displayExpression is more common in risk record display config.

clearOnHide

When an element is hidden by hideExpression, its value is preserved by default — the field is hidden but the existing value remains. To clear the value when the field is hidden, set clearOnHide: true:

{
  "key": "mtaReason",
  "label": "MTA Reason",
  "type": "select",
  "hideExpression": "model.riskType !== 'MTA'",
  "clearOnHide": true
}

This is important for data integrity: without clearOnHide: true, a value entered when the field was visible persists even after the field is hidden, and will be saved on form submission.

Configuration

{
  "key": "targetPremium",
  "label": "Target Premium",
  "displayExpression": "model.targetPremium > 10000"
}

The model object is the full JSON response from GET /v2/risks/{id}.

Examples

Show a field only for a specific placing type:

model.placingType === 'COVERHOLDER'

Hide a field for certain placing types:

!['COVERHOLDER', 'MASTER'].includes(model.placingType)

Show a field only for MTA risks:

model.riskType === 'MTA'

Show a field based on inception date:

new Date(model.inceptionDate).getTime() < new Date().getTime()

Date comparison note

Warning

Date comparisons in JavaScript use the user's local timezone. Always compare using UTC methods to ensure consistent results across users in different timezones:

new Date(model.inceptionDate).getTime() < Date.now()


Operation-level visibility

At the operation level within a risk action, two simpler flags are available:

Flag Description
displayIfStatePresent Show this operation button only if a specific sub-status is present on the action instance
displayIfStateNotPresent Show this operation button only if a specific sub-status is NOT present

These are simpler than full displayCriteriaExpressions and are commonly used to show/hide individual buttons within an action (e.g. show the Edit button only after the action is complete).