JavaScript
In this section, we cover some of the built-in variables and functions available to the JavaScript expression syntax.
Last updated
In this section, we cover some of the built-in variables and functions available to the JavaScript expression syntax.
Last updated
When creating workflows, you'll often need to write dynamic expressions. This page provides an overview of enabling JavaScript expressions and what functions and objects you can use.
The JavaScript Expressions feature is provided by the following package:
You can enable the feature as follows:
The UseJavaScript
extension provides an overload that accepts a delegate that lets you configure JintOptions
. These options let you configure the underlying engine.
For example:
The following functions and objects are available as globals to all JavaScript expressions:
get{InputName}
get{VariableName}
set{VariableName}
The JSON
type provides static methods to parse JSON strings into JavaScript objects and to serialise JavaScript objects into JSON strings.
The variables
object provides static access to the workflow variables. For example, if your workflow has a variable called OrderId, you can get and set that workflow variable using the following JavaScript expression:
Returns the workflow definition ID of the currently executing workflow.
Returns the workflow definition version ID of the currently executing workflow.
Returns the workflow definition version of the currently executing workflow.
Returns the workflow instance ID of the currently executing workflow.
Sets the correlation ID of the currently executing workflow to the specified value.
Gets the correlation ID of the currently executing workflow.
Sets the specified workflow variable by name to the specified value.
Gets the specified workflow variable's value by name.
Gets the specified workflow input by name.
Gets the specified activity output by name from the specified activity by name.
Gets the output of the last activity that executed.
Returns true
if the specified string is null, empty or consist only of whitespace characters, false
otherwise.
Returns true
if the specified string is null or empty, false
otherwise.
Parses the specified string into a Guid
.
Creates a new Guid
.
Creates a new Guid
as a string
representation.
Creates a new short GUID as a string
representation.
Converts a byte array to a string.
Converts a string to an array of bytes.
Converts a byte array to a base64 string.
Converts a base64 string to a byte array.
Converts a string to a base64 string.
Converts a base64 string to a string.
Elsa uses to implement the JavaScript expression evaluator.