Note
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:
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()
.type("media-asset")
.name("demo asset 1")
.build();
assetService.createAsset(asset);
}
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).
The following actions provide support for scripting:
Actions
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:
The following pages are useful guides to help accelerate the writing of Flex scripts:
Please see the Examples page for details on how to write scripts.