Built-in Object Interfaces
The Python implementation provides two primary interfaces that expose the built-in variables listed below and enable access to scripting context.- ScriptContext
- ScriptItem
ScriptContext
This interface represents the primary scripting context for Python scripts in . It provides dictionary-like access to items and includes logging capabilities. The interface exposes the_ctx variable, which you use to access and manage the scripting context.
Available methods for this interface are as follows:
-
push -
log
ScriptItem
This interface represents individual data items in the scripting environment. It provides dictionary-like access to attributes and maintains lists of values for each item. The following variables are pre-instantiated ScriptItem objects that are available automatically :-
_input -
output
-
get -
clear
Understanding How ScriptContext and ScriptItem Work
The ScriptContext and ScriptItem interfaces work together to manage how data is accessed and processed within a script. The_ctx variable represents the overall scripting context and allows you to access or define items. You can use the syntax _ctx.itemname to create new items or access existing ones dynamically within the script.
The _input and output variables act as containers for data within the scripting context. The _input variable holds and exposes incoming data while the output variable holds and defines outgoing data.
Within this model, scripts typically read data from _input, use _ctx to access or organize items, and write results from output.
For more details, see Built-in Variables and Operations.
Built-in Variables
The built-in variables (_ctx, _input, and output) provide access to the core of the message context in a scripting environment. Use these variables to interact with the items that are available in the scripting engine.
_ctx
The_ctx variable is the primary way to access to the scripting environment. It provides access to all items that are available in the script and enables you to create new items, push items, and write entries to the application logs.
In the following example, the log method on the _ctx variable is used to write an entry to the application log at the INFO level:
_input
The_input variable represents the read-only input item of the scripting engine. The available attributes vary based on the context in which you are writing your event. For example, in an event that executes after a job, the following inputs are available:
-
ConnectorId -
WorkspaceId -
MessageId -
FilePath -
FileName -
Attachment# -
Header:*
output
Theoutput variable is a built-in item that serves as an alternative to creating and pushing your own item when only a single output is needed. Unlike custom items that require you to explicitly call the push() method to send them as output, the output item is pushed automatically when the script completes. You just need to modify its properties and it is automatically pushed as output after the script execution is complete, without any additional push() calls needed.
You can set attributes directly on the item or define them by using a dictionary (dict), and you can do the same thing with items that you define yourself. The following example pushes an output file with some data:
Operations
The following operations are available in the scripting environment to interact with the scripting context and items.-
clear -
get -
log -
push
clear
Theclear() operation clears the ScriptItem on which the method is called. The item remains the same, just empty.
get
Theget(attr) operation returns the value of the specified attribute on the ScriptItem. This operation provides a programmatic way to access item attributes by name. It is functionally equivalent to accessing the attribute directly using dot notation (for example, _input.myattr) or using dictionary-style access (for example, _input.get('myattr')).
The following example prints the value list of the tags attribute on the item object to the log file of the current script:
log
Thelog(level, message) operation, available on the _ctx variable, allows you to write entries directly to the application log. The available log levels are DEBUG, INFO, WARNING and ERROR.
The following example uses the Python logging context to record an error-level message when data evaluation fails for a specific connector:
push
Thepush(item) operation pushes the supplied item as output of the script. If no item is specified, the current output item is pushed.
In the following example, a new item (foo) is created in the ScriptContext, assigned some data and a filename, and then pushed out.