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.

{
     "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,

    },
    "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"]
    },
    "translations": {
        "price": {
            "en": "Price",
            "nl": "Prijs",
            "de": "Preis",
            "fr": "Prix",
            "es": "Precio",
            "pl": "Cena"
        },
    },
    "settings": {
        "company": "Maxedy"
        }
    }
}

Object properties

Key Description
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
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.
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

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