Skip to main content

Environment

The Environment functions allow a package to explore the records configured in the environment that it runs in. A package can look up a record by name or iterate over all records of a type. Currently only the account records are available.

Environment.account​

Returns the details of the account with the given name, as configured in the Accounts tab of the environment. Which attributes are available depends on the type of the account.

const account = Environment.account("wdc");

Every account has these attributes:

  • name: the name of the account.
  • type: the type of the account: xurrent, http, soap, aws, ms-graph, proxy, file-repository, mysql, mssql or ssh-sftp.

A Xurrent account contains the following extra attributes:

  • url: the URL of the Xurrent REST API, for example https://api.xurrent.com/v1.
  • users: the users of the account (the "API users"), in the order in which the credentials are configured. Each user is an object with a personId. A user with multiple credentials is listed once, and credentials that have not been verified are not included in the list.

An HTTP account also contains:

  • url: the URL of the account.
  • username: the username of basic authentication.

An error is raised when there is no account with the given name.

Example:

Add all users of a Xurrent account as approvers, so that the automator can always approve a task regardless of which credential is used:

const users = Environment.account("wdc").users;
users.forEach((user) => addApprover(task.id, user.personId, "wdc"));

Environment.accounts​

Returns all accounts of the environment, with the same attributes as Environment.account.

Example:

Find all Xurrent accounts whose name starts with a certain prefix:

const accounts = Environment.accounts();
accounts.filter((a) => a.type === "xurrent" && a.name.startsWith("wdc-"));