Variables in JavaScript insertions

🌐 This document is available in both English and Ukrainian. Use the language toggle in the top right corner to switch between versions.

When modeling UI forms, sometimes you need to define the specific behavior of a component. To do this, you can use the parameters that support custom JS code:

  • Calculated Value

  • Custom Default Value

  • Custom Validation

  • Advanced Conditions

These parameters can contain regular JS code that will be executed in the user’s browser. Usually, a set of variables is available when this code is executed. Each parameter has its own set of variables, but most are shared.

1. Tips for developers

1.1. Debug

Use the console.log function in JS insertions to check the execution of a script and find a possible error. When this function is called, it prints the values of its arguments to the browser console.

For example:

eval debug settings

Sequentially entering the characters 1, 2, 3, and 4 into the Text Field gives us the following:

eval debug result

How you open DevTools depends on your browser—​for example, Ctrl + Shift + I for Chrome.

2. Available variables

2.1. data

An object with the current form data. This object is sent to the backend API when the task is completed.

2.2. instance

The current component. This object contains many methods and properties that differ between components. You can read more about specific properties on the pages of individual components.

2.3. input, value

The value of a component. Some parameters provide input; others provide value.

2.4. row

This variable is only available if the current component is in an Edit Grid component. This is a reference to a specific element of the table—​the one currently being edited.

2.5. formVariables

Business process variables. For details, see arch:archive/admin-form-variables.adoc

2.6. currentUser

An object that contains information about an authenticated user. This object is available to all plugins. For details, see the Get user profile API.