StrykeLibrary

The Stryke Library provides access to execution data and methods that can be used by the scripts to interact with Stryke. All scripts will have a global instance of the stryke library ready to use. This instance can be accessed via the global variable "stryke". The stryke library variable is read-only, its methods and properties cannot be modified.

All execution paths within a script must be resolved by calling either stryke.resolve or stryke.error. Failing to resolve a path that is executed will result in the script timing out.

Properties
user (UserInfo) : The details of the user that is executing the script.
data (ExecutionData) : An object to access data specific to this script execution (example: the trigger record, or request payload).
Instance Members
create(entityName, data, callback)
error(errorFromScript)
find(queryString)
findOne(queryString)
query(queryString, applyAccessControl, callback)
resolve(data)
update(recordId, data, callback)

ExecutionData

The ExecutionData object holds execution data, which can be used by scripts at run time.

For example, the execution context can hold the record in context for the current execution, or the old and new values of a record in a trigger execution.
As with all members of the stryke global variable, stryke.data (which holds the ExecutionData instance for each execution) is read-only. If you wish to modify the values within an object held inside stryke.data you need to make a copy of the object first. Example:

const mutableREcordInContext = {...stryke.data.record};
Properties
record (object) : The record in context for this script execution. This is the record from which an action was executed. For example if the action is of type "button", record will contain the record on which the button was clicked.
requestData (object) : Any data that was passed as payload (ie the body of the HTTP request) to the original script or action execution request. This can be used to pass request specific arguments to the script being executed. The payload must be in valid JSON format.
new (Array<Object>) : Set when executing a create or update trigger script. This property holds an array containing the records that are being created or updated (with the new values that will be applied by the update operation). If only a single record is being created or updated, the array will only contain 1 element. 'new' is not set in delete triggers.
old (Array<Object>) : Set when executing an update or delete trigger script. This property holds an array containing the records that are being updated (with the old values that will be overridden by the update operation) or deleted. If only a single record is being updated or deleted, the array will only contain 1 element. 'old' is not set in create triggers.
recordBefore (object) : Deprecated - Set when executing an update or delete trigger script, it holds the single record or first record in the array of records that are being updated or deleted. This is equivalent to the first entry of the 'old' array. Important: Use 'new' instead of this property and implement your triggers following a bulk approach.
recordAfter (object) : Deprecated - Set when executing a create or update trigger script, it holds the single record or first record in the array of records that are being created or updated. This is equivalent to the first entry of the 'new' array. Important: Use 'new' instead of this property and implement your triggers following a bulk approach.

UserInfo

A model containing information about the user that is executing a script.

Properties
id (string) : The id of the user executing the script
username (string) : The username of the user executing the script
email (string) : The email of the user executing the script