Records Actions API in Siren Investigate

context.registerActions

The context global variable provides a registerActions function you can use to register records actions in the Siren Platform.

At the moment, you can only register one records action per script:

Example

const mainRecordsActionDefinition = async (recordIds, actionOptions) => {
  await sirenapi.Collection.addCollectionRecords({ recordIds })
}

context.registerActions({
  actionName: { action: mainRecordsActionDefinition }
});

Properties

Name Type Description

[action-name]

Record<string, ActionDefinition>

Records action definition.

ActionDefinition

An object that defines a records action to register with context.registerActions.

Properties

Name Type Description

action

Function

The function definition to be invoked for the given records action.


ActionDefinition.action(recordIds, actionOptions)

Returns the output of the records action.

The action function can be either be synchronous or async.

Parameter Type Description

recordIds

DataModelEsRecordId[]

Array of data model record ids which can be read and mutated in the body of the action function definition.

actionOptions

ActionsOptions

Additional action options which can be read by the action function definition.

Returns: Promise<any> | any.

ActionsOptions

Records actions options to determine the relevant operations for the current action and passed records.

Name Type Description

origin

ScriptOrigin

A ScriptOrigin instance used by Investigate to keep track of the running script context. Some SirenAPI functions require this information to infer how to behave.