Info about the action
Scripts offer the capability to retrieve details about the actions that trigger their execution. This can be accomplished by accessing the actionInfo
variable. Utilizing actionInfo
allows you to gain insights into the specific action responsible for the script's activation.
To capture and review this information, you can log the actionInfo
variable to the console. Here's how you can do it:
console.log(actionInfo);
{
"newStatus":"9000",
"actionName": "updateDocument_1",
"actionNameV1": "updateDocument",
"googleAPIKey": "AIzaSyAF82h_fpSXMIOrFM13SyNX24ei4HMXkiY",
"environmentId": "A9rYaGTFKPrT5",
"suppressSuccessMessage": false,
"type": "userAction",
"currentUser": {
"_id":"a6gA9rYaGTFKPrT5P",
"username":"admin",
"name":"Jonathan de Boer",
"email":"jdboer@company.nl"
"administrator": true,
"language": "en"
},
"selectedLines":{
"orderLine":["dqxAf3uKEBEqN92b7"],
"invoiceLine":["naknkDw3Kd7PnZBvM","d2DR7beWx5KZijf4o"]
},
"translations": {
"price": {
"en": "Price",
"nl": "Prijs",
"de": "Preis",
"fr": "Prix",
"es": "Precio",
"pl": "Cena"
},
},
"settings": {
"company": "Maxedy"
}
},
"impersonator": {
"_id" : "7MYeNmJC3xqrfQYRy",
"name": "Impersonator Name"
},
"event": {
"type" : "PURCHASE_ORDER_CREATED",
"info": {
"invoiceId": "00a59940-8ad0-4f46-806d-8dfe5e33c17e"
}
}
}
Object properties
Key | Description |
---|---|
actionName | The name of the action that triggered the script. |
actionNameV1 | The name of the action that triggered the script when the document definition was converted from BizzStream version 1. |
newStatus | In a workflow, an action can be connected to a target status. In this case the field will contain the name of the target status. If the action does not have a target status, the field will have the value null. It is not possible to update the status of a document by changing actionInfo.newStatus . |
googleAPIKey | The API key of Google as set in the environment. |
environmentId | The ID of the environment. |
type | Shows the type of action performed. |
currentUser | This field contains an object with information about the user who executed the user action. This field is only available if the script has been started through a user action. If the document is opened by a visitor who is not logged in as user, the object will contain information about the visitor. |
selectedLines | This object contains information about the lines a user has selected. This field is only available if the script has been started through a user action. Per line in the layout, the object contains an array with the IDs of selected lines. |
translations | This object contains the keys and values of each translation used in the environment. |
settings | This object contains the settings that you can configure via the settings page. |
impersonator | This object contains the ID and name of the user who impersonated the current user. |
event | This object contains the type and info object of the event that triggered the Event Action. |
Using translations in script
The following example shows how you can use translations in scripts:
var message1 = actionInfo.translations.xxx[yyy];
var message2 = actionInfo.translations[xxx][yyy];
//Replace xxx with the translationkey and yyy with the language code (en/nl/fr/es/de/pl)
//Used in an example with the translationkey price in English.
var message1 = actionInfo.translations.price["en"];
var message2 = actionInfo.translations["price"]["en"];