Trigger

Availability table

Controller availability

Module

Available

module.scripts

Supported feature

module.keycloak

Not supported feature

trigger controller

The trigger represents the cause of the script execution. Its runtime type depends on the execution context:

  1. VALUE_SCRIPT execution: - The trigger is a ScriptValue instance

  2. PARAMETER_SCRIPT execution (manual call, web call, etc.): - The trigger is a ScriptParameters instance

  3. PARAMETER_SCRIPT callback - The trigger is a ScriptValue instance

TYPE CHECKING (RUNTIME)

To safely determine the trigger type at runtime, you must rely on type checking:

Recommended approach :

switch (trigger.triggerType) {
    case "VALUE_SCRIPT":
        trigger.getContent();
        break;

    case "PARAMETERS_SCRIPT":
        trigger.parameters;
        break;
}
if (trigger.triggerType === "VALUE_SCRIPT") {
    return;
}
// From there the IDE deduct the type

TYPE OVERRIDE (JAVASCRIPT / JSDOC)

You can force a specific type for IDE / static analysis purposes only.

IMPORTANT: - This does NOT change runtime behavior - This ONLY affects type checking in the editor

Example:

/** @type {import("trigger_controller").ScriptValue} */
var trigger;

or:

/** @type {import("trigger_controller").ScriptParameters} */
var trigger;

Use this only when you KNOW the execution context in advance.

WARNING

Do NOT rely on @type to determine runtime behavior. Always use trigger.triggerType() or structural checks.

scriptParameters

The trigger is the cause of the execution of a script.

scriptParameters.getId()

ItemId of this script in format root.myscript

Returns:

The item ID in format root.myscript

scriptParameters.getParameters()

The list of parameters configured from the source who trigger the scripts, this can be set by the web or from the script execution

Returns:

The list of parameters configured from the source who trigger the scripts, this can be set by the web or from the script execution

scriptValue

The trigger is the cause of the execution of a script, a script value contains the data from the value who is associated with the script.

Note: When used in a ValueScript, the same type apply for myself.

scriptValue.getContent()

The content of the value when the trigger has changed. The value is a copy of the triggered value. The value can be empty or null

Returns:

The content of the value when the trigger has changed. The value is a copy of the triggered value. The value can be empty or null

scriptValue.getDescription()

The description field from the value.ospp

Returns:

The description field from the value.ospp

scriptValue.getError()

The content of error if present otherwise set to “”

Returns:

The content of error if present otherwise set to “”

scriptValue.getId()

The ItemId of the value in the format of root.myscript

Returns:

The ItemId in string format root.myscript

scriptValue.getName()

The name from the value.ospp

Returns:

The name from the value.ospp

scriptValue.getTimestamp()

The timestamp at the moment the value was changed in nanoseconds since EPOCH

Returns:

The timestamp at the moment the value was changed in nanoseconds since EPOCH

scriptValue.getType()

The type of content

Returns:

The type of content

scriptValue.isError()

The content of error if present otherwise set to “”

Returns:

The content of error if present otherwise set to “”