Script Actions
Using Script Actions
Script Actions allow you to write custom code to transform data, perform calculations, or implement custom logic. Moveworks currently supports a variation of Python called APIthon.
To provide a secure runtime, each Script Action adds non-negligible latency to your plugins. Please make sure to use DSL and our Data Mapper for common data transformation operations.
Option 1: Creating a standalone Script Action
You can create a standalone script action inside of the Plugin Workspace, under Actions > Script Actions. Once created, this action can be referenced inside of plugins through Action Activities.
Script Action Editor
The standalone Script Action editor includes:
- Language selector - Choose between APIthon (default) or Python (if enabled).
- Code editor - Write your script code here. Make sure to end the script with your return value.
- Input Args button - Opens the Input Arguments panel to define inputs for your script.
- Test button - Execute your script with the example values you defined.
Defining Input Arguments
Click the Input Args button to open the Input Arguments panel. Click Create New to add an argument with the following fields:
| Field | Required | Description |
|---|---|---|
| Argument Name | Yes | The variable name to use in your script (e.g., customerName). |
| Data Type | Yes | The type of the argument. See Data Types below. |
| List[T] | No | Check this box if the argument is a list of the selected data type. |
| Example Value | No | A test value used when clicking the Test button. |
| Description | No | Describe the purpose of this input argument. |
| Required | No | Check if this argument must be provided when calling the action. |
Click Save to save the argument.
Data Types
The following primitive data types are available for Script Action arguments:
| Type | Description | Example Value |
|---|---|---|
string | Text values | John Doe |
integer | Whole numbers | 123 |
number | Decimal numbers | 3.14 |
boolean | True or false | true or false |
array | JSON array (mixed types allowed) | [1, "two", true] |
object | JSON object | {"name": "John", "age": 30} |
Using List[T] for Lists
Check the List[T] checkbox to indicate the argument is a list of the selected type. The example value must be a JSON array where each element matches the base type.
| Data Type | With List[T] | Example Value |
|---|---|---|
string | List[string] | ["apple", "banana", "cherry"] |
integer | List[integer] | [1, 2, 3, 4, 5] |
object | List[object] | [{"id": 1}, {"id": 2}] |
NoteThe
arraytype accepts mixed types within the array, whileList[T]enforces that all elements are of type T.
Option 2: Creating a Script Action inside a Compound Action
You can insert a script action directly inside a Compound Action using the script keyword.
YAML Fields for Compound Action Scripts
When adding a script inside a Compound Action, use the following YAML fields:
- script:
output_key: result_variable
input_args:
arg_name: data.some_value
code: |
# Your APIthon code here
return arg_name.upper()| Field | Required | Description |
|---|---|---|
output_key | Yes | A variable name to store the result of the script. |
input_args | No | A dictionary mapping argument names to values. Accepts Moveworks Data Mapping Syntax. |
code | Yes | A string containing the code to execute. |
Supported Languages
Moveworks currently supports a variation of Python called APIthon. This provides a familiar and powerful scripting environment for developers.
Follow our roadmap item to be the first to get full Python support in your instance.
Updated 14 days ago