Dalet Flex documentation has moved!
This page is no longer actively maintained. For the latest documentation, please visit us at our new support portal: https://support.dalet.com

Spring Expressions

We support the use of Spring expressions in Enterprise. The same objects available in the JBPM context are also available in the Spring context, and thus can be used for Spring expressions as well.

Spring expressions must start with #{ and end with }. When Spring expressions are enabled, you must use # instead of $.

  • Spring Expressions are not currently supported in configuration fields for actions created using the Job Execution Framework.
  • Event handlers can only be configured using Spring expressions.
  • Objects in the expression language are based on the internal Dalet Flex object model, and not the B2B API model.
  • See the official Spring Expression guide for more information. This guide focuses on the advanced features of the Spring expression language.
  • For workflow variables, you must use the syntax #{variables['<variable name>']} instead of ${variables.<variable name>} .
  • You can combine the current expression language with Spring expression language in different fields.

Examples:

Description Expression Language Spring Expressions
Returns the description of an asset ${asset.description} #{asset.description}
Returns the ID of a user ${user.id} #{user.id}
Returns the first name of a user ${user.firstName} #{user.firstName}
Returns the last name of a user ${user.lastName} #{user.lastName}
Returns the company of a user ${user.company} #{user.company}
Returns the email address of a user ${user.email} #{user.email}
Returns the name of a UDO ${object.name} #{object.name}
Returns the title of an asset ${asset.title} #{asset.title}
Returns active proxies for a file asset ${asset.activeProxies} #{asset.activeProxies}
Returns the ID of an event (Used on event handlers) ${event.id} #{event.id}
Returns the ID of a job ${job.id} #{job.id}
Returns the due date of a job ${job.dueDate} #{job.dueDate}
Returns the start date of a job ${job.startDate} #{job.startDate}
Returns the end date of a job ${job.endDate} #{job.endDate}
Returns the priority of a job ${job.priority} #{job.priority}
Returns the current state of a job ${job.jobState} #{job.jobState}
Returns the ID of a workflow ${workflow.id} #{workflow.id}
A boolean expression on an event handler ${event.flexManagedObject.variant.name == "Media"} #{event.flexManagedObject.variant.name == "Media"}
User Enabled Event Handler ${event.flexManagedObject.id} #{event.flexManagedObject.id} until Dalet Flex 2021.4.0 and #{event.mioObject.id} from Dalet Flex 2021.5.0
Password Reset Event Handler ${event.mioObject.name} ${event.mioObject.name} until Dalet Flex 2021.4.0 and #{event.mioObject.id} from Dalet Flex 2021.5.0
Applies a run-rule expression in a Copy action details page ${asset.mioObject.approved} #{asset.mioObject.approved}
Execute Launch Workflow with an import action ${variables.externalFileName} #{variables['externalFileName']}
Executes a Segmented Proxy action via a workflow ${variables.videoAssetIds} #{variables[‘videoAssetIds’]}
Executes a Segmented Proxy action via a workflow ${variables.audioAssetId} #{variables['audioAssetId']}
Obtains the value of a workflow variable with this name (This can be a string, object, or date) ${variables.varName} #{variables['varName']}
Returns the current version of a workflow ${workflow.version} #{workflow.version}

Spring Expressions for event handlers

Only Spring expressions can be used for the configuration of event handlers. You can use Spring expressions to filter for events with specific values, or to ensure event handlers only run when certain fields are present. Below is a non-exhaustive set of event fields and sub-fields accessible via Spring expressions. You should also be able to access most other fields present in the full JSON representation of the event. To do this, build out the expression like you see in the below examples, starting with the top level event and adding each layer on the path to the field in question. Each layer on the path corresponds to each layer of data in the JSON event.

For example, consider the following JSON:

{
  "event": {
    "object": {
      "id": 123
    },
    "anotherField": "someValue"
  }
}

If you wanted to match against the value of the id field, you would start at event, add object, and end in id, giving you the path event.object.id. You could then use this path in a Spring expression like so: #{event.object.id == 123}, or #{event.object?.id == 123} to be null-safe (more information on that at the bottom of the page).

If you wanted to match against the value of anotherField, you could follow the same process to build the path to the field you would like to target; in this case, the path would be event.anotherField, which could then be used in a Spring expression like #{event.anotherField?.startsWith("some"}. This expression would return match against all events with an anotherField value beginning with “some”.

Selected event fields and examples

Asset fields:

Field Expression Language Example Notes
ID #{event.asset?.id == 123}
External IDs #{event.asset?.externalIds.^[key == "particularExternalKey"] != null} Target assets that have a particularly-named external ID
Media region #{event.asset?.mediaRegion?.sourceTimestampIn < 200000} Target assets that have a media region and source timestamp in of less than 200000 milliseconds
Composition asset tracks #{event.asset?.compositionAssetTracks?.size() > 2} Target assets that have more than two composition asset tracks
Asset origin #{event.asset?.assetOrigin == "Proxy"} Other possible asset origin options include “Ingest”, “Import”, “New”, etc. Please note that this match is case-sensitive
Locked #{event.asset?.locked == true}
Parent asset #{event.asset?.parentAsset?.id == 456} Good for targeting all children of a given asset
Variant #{event.asset?.variant?.id == 789}

Object fields:

Field Expression Language Example Notes
ID #{event.object?.id == 123}
Account ID #{event.object?.account?.id == 456}
Workspace ID #{event.object?.workspace?.id == 789}
Display name #{event.object?.displayName?.startsWith("Common Prefix")} Targets objects that have display names starting with the given string value – this would be "Common Prefix" in the given example. Please note that this match is case-sensitive

Object type fields:

Field Expression Language Example Notes
ID #{event.objectType?.id == 123}
Name #{event.objectType?.name == "Some Object Type"} Example names: “media-asset”, “image-asset”
Display name #{event.objectType?.displayName == "Some Object Type Display Name"} Example display names: “Media Asset”, “Image Asset”
Metadata supported (boolean) #{event.objectType?.metadataSupported == true}
Attachments supported (boolean) #{event.objectType?.attachmentsSupported == false}
Comments supported (boolean) #{event.objectType?.commentsSupported == true}

User fields:

Field Expression Language Example Notes
User ID #{event.user?.id == 123}
User’s first name #{event.user?.firstName == "First"}
User’s last name #{event.user?.lastName == "Last"}
User’s role #{event.user?.role?.id == 456} You can also access other role fields, such as id and name
Owner’s full name #{event.ownerFullName == "John Doe"} Convenient way to match against a user’s full name

Event data:

Event data – the section of the event containing data specifically tied to the event type – can be accessed using a method called getDataValue, like so: event.getDataValue("someEventDataField").get().

It is often the case that users would like to filter events based on the content of nested event data fields. This occurs, for example, when checking the value of a taxonomy field change. Consider the following event data JSON snippet:

{ 
  "eventData": [
      {
          "name": "asset-status",
          "value": "{\"mode\":\"updated\",\"before\":\"Rejected\",\"after\":\"Approved\"}",
          "type": "JSON"
      }
  ]
}

Here, the event data value field contains escaped, nested JSON. Let’s assume that the requirement is to only run the event handler when after equals Approved in the value field’s nested JSON. Unfortunately, we cannot access these fields using a path like we do other fields in the event (like event.object.id, event.asset.displayName, etc). Instead, we can use regex to target String values contained in the value field. For the above example, that would look like this: #{event.getDataValue("media-status").get().value.matches("(.*)after(.*):(.*)Approved(.*)")}. The (.*) statements allow us to sidestep the issue of the escaped quotation marks, but they do so at the potential cost of reducing the precision of the regex. If using such an expression, be sure to test the event handler to make sure it behaves as expected in all scenarios.

Scenario Expression Language Example
Check if field is present and non-blank #{event.getDataValue('myEventDataField').isPresent() && event.getDataValue('myEventDataField').get().length > 0}
Match specific value in escaped, nested JSON #{event.getDataValue("media-status").get().value.matches("(.*)after(.*):(.*)Approved(.*)")}
Check that a field DOES NOT match a specific value in escaped, nested JSON #{!event.getDataValue("media-status").get().value.matches("(.*)mode(.*):(.*)updated(.*)")}

Technical notes:

  • The question marks used in the examples ensure that the field is not null before continuing. This prevents null pointer exceptions in the logs.
  • SpEL provides many convenience methods for collections (lists, sets, maps, etc). You can use these convenience methods when targeting event fields that are collections, such as external IDs, placed media regions, and so on. There are some usage examples on this page, but you can also refer to the official Spring documentation for more advanced functionality in this area.