Skip to main content

Execution

The Execution functions give insight into the context of the package execution that is currently running. A package can look up the ID of the execution, the account it runs for, and the person that triggered it.

Execution.id​

Returns the ID of the current package execution, in the short form shown in the execution logs. This makes it useful for linking a note or an e-mail back to the logs.

const executionId = Execution.id();
// => "3f2a9c1e"

Execution.uuid​

Returns the full UUID of the current package execution. The short ID returned by Execution.id consists of its first eight characters.

const executionUuid = Execution.uuid();
// => "3f2a9c1e-7b4d-4e2a-9c1f-5d8e6a7b9c0d"

Execution.account​

Returns the details of the account that triggered the execution, or null when the execution has no account (for example a package triggered by an inbound e-mail). Which attributes are available depends on the type of the account, see Environment.account.

const account = Execution.account();
// => {
// name: "wdc",
// type: "xurrent",
// url: "https://api.xurrent.com/v1",
// users: [{ personId: 7273209 }, { personId: 7829021 }]
// }

Execution.triggeredBy​

Returns the person that triggered the Xurrent webhook event that started this execution. Returns null when the execution was not started by a Xurrent webhook, for example by a schedule, an inbound e-mail or a service call.

const person = Execution.triggeredBy(); // { personId: 6451631 }

Execution.isTriggeredByAccountUser​

Returns true when the event that triggered the execution was caused by one of the users of the account, that is, through one of its credentials. Use it to avoid loops in packages that allow such webhook events:

if (Execution.isTriggeredByAccountUser()) {
log("Skipping change made by the automator itself");
return;
}

Note that it checks every credential of the account, so it also works for accounts with multiple tokens.