Skip to content

Info about the action

From scripts it is possible to request information of the actions that are responsible for the execution of the script. You can do this by calling the variable actionInfo.

The following code saves the actionInfo variable to the logs

console.log(actionInfo);

The result is an object with the information of the action responsible for the execution of the script.

{
     "newStatus":"9000",
     "newStatusLabel": "definitive",
     "googleAPIKey": "AIzaSyAF82h_fpSXMIOrFM13SyNX24ei4HMXkiY",
     "environmentId": "A9rYaGTFKPrT5",
     "suppressSuccessMessage": false,
     "layoutId": "PDnwpc2Epexzqm4rm",
     "confirmedRules": {},
     "type": "userAction",
     "currentUser": {
        "_id":"a6gA9rYaGTFKPrT5P",
        "username":"admin",
        "name":"Jonathan de Boer",
        "email":"jdboer@company.nl"
        "administrator": true,
        "language": "en"
    },
    "clientSystem":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.117 Safari/537.36",
    "selectedLines":{
        "orderLine":["dqxAf3uKEBEqN92b7"],
        "invoiceLine":["naknkDw3Kd7PnZBvM","d2DR7beWx5KZijf4o"]
    },
  "overviewDocumentIds": [ 
        "3DKKq68tvhpu9bk24",
        "90f56538c1fb334258952bda",
        "i6Z3DzmccKKp4WExZ",
        "xBbMNXwKeFgmD3gFv",
        "xDhNvXfDaj77Daiqs" 
    ],
    "translations": {
        "price": {
            "en": "Price",
            "nl": "Prijs",
            "de": "Preis",
            "fr": "Prix",
            "es": "Precio",
            "pl": "Cena"
        },
    },
    "settings": {
        "company": "Maxedy"
        }
    },
    "impersonator": {
      "_id" : "7MYeNmJC3xqrfQYRy",
      "name": "Impersonator Name"
    }
}

Object properties

Key Description
actionName The name of the action that triggered the script.
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.
newStatusLabel In a workflow, an action can be connected to a target status. In this case the field will contain the label of the target status. If the action does not have a target status, the field will have the value null.
googleAPIKey The API key of Google as set in the environment
environmentId The ID of the environment
suppressSuccessMessage Shows whether the success notification will be shown to a user
layoutId The ID of the layout the action is triggered from
confirmedRules Part of the guard rules
clientSystem Information about the operating system and browser of the user
overviewDocumentIds A list of all documentIds that were displayed in the overviewGrid. The sorting and filtering settings in the overviewGrid are applied on this list of documentIds.
type Shows the type of action performed
currentUser This field contains an object with information about the user that 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.

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"];