Flex Scripting Framework


Starting with Flex 2020.6.0, Flex has a re-written scripting engine and actions, which provide improved scalability and security enhancements. Within the documentation we refer to the old scripting actions as “legacy actions”. There are also no longer any “external” scripting actions, as the ability to use external scripting JARs has been incorporated into the “internal” scripting ones.

One of the most powerful aspects of the Flex platform is the ability to be able to write scripts to perform custom processing. For example, you could make an external HTTP REST call, inserting the results as asset metadata values. Within scripts, Flex provides an SDK that allows you to manipulate configuration and objects in a standard and well-defined manner.

There are 2 ways to write scripts within Flex:

  1. Groovy script
  2. External scripts - compiled JVM-compatible code in JARs (e.g. Groovy, Java, Scala)

Groovy scripts are added to supported actions, via their configuration. Note that Flex currently supports Groovy v3.0.4.

The following is an example script, which could be executed in a JEF Script action, which creates a new media placeholder asset:

def execute() {  
  def assetService = flexSdkClient.getAssetService();
  NewAssetPlaceholder asset = NewAssetPlaceholder.builder()
        .name("demo asset 1")

External scripts are compiled code packaged in to JARs, and hosted via a standard URL (e.g. HTTP, file). These allow customers to write re-usable and testable binaries (see External Scripts for more information).

Scriptable Actions

The following actions provide support for scripting:


Type New Action Legacy Action Purpose
Decision    JEF Script Decision Groovy Scripted Decision Action Controls workflow simple branch execution via the return value of a groovy script
JEF Script Multi-Decision Groovy Scripted Multi-Decision Action Controls workflow complex branch execution via the return value of a groovy script
Message JEF HTTP Message Scripted HTTP Message Sends an HTTP message, allowing the request and/or response to be processed via groovy script
Script JEF Script Groovy Script Action Executes either internal or external scripts
Wait JEF Wait For Named Signal Groovy Scripted Wait For Named Signal Action     Pauses workflow execution until a signal is received. Groovy script can be used to control whether the action should wait for the signal
JEF Wait For Script Groovy Scripted Wait Action Pauses workflow execution until a groovy script returns true, or times out

Timed Actions

New Action Legacy Action Purpose
JEF HTTP Message Timed HTTP Message Sends an HTTP message on a schedule, allowing the response to be processed via groovy script
JEF Script Timed Groovy Script Executes internal or external groovy scripts on a schedule

The new actions execute via the flex-jobasyncexecutor-service, and as such, any scripting interactions with Flex occur via its REST APIs. The legacy scripting actions ran on the FLEX job nodes, but this was changed to provide greater scalability. As a consequence of this, the following points should be noted:

  • Scripts are no longer transactional. This means that if an exception is thrown during script execution, it is now the responsibility of the script developer to catch it and leave the system in a valid state (see Transactions within Scripting ).
  • There are restrictions as to the JVM features and classes allowed to be called (see Script Restrictions)
  • Logging from the SDK context no longer generates events (as this was overloading the events system in some cases), so instead they are send to Kibana (see Logging within scripts).
  • The new SDK does not fully match the legacy SDK (see Legacy SDK Compatability).

Help writing scripts

The following pages are useful guides to help accelerate the writing of Flex scripts:

Example scripts

Please see the Examples page for details on how to write scripts.