Top.Mail.Ru
Running Script from Dashboard
CTRL+K

Running Script from Dashboard

In this article
  • Running Script from Dashboard
  • Configuring a Script
  • Adding an Action to a Table
  • Configuring the Action
  • Action Configuration Parameters
  • Configuring the Input Method
  • Action Execution
  • Examples of Running Scripts from Dashboard
  • Adding Row
  • Script and Action Configuration in YAML

When working within a single space, it is possible to run a script directly from a dashboard without switching to the script editor. It can be configurated in the Table widget.

Some usage examples include:

  • Adding, deleting or updating table rows
  • Performing an action in another system:
    • Creating issues
    • Increasing the priority of an issue
    • Sending messages

Configuring a Script

To launch a script from the dashboard, create a script that can be used for configuring an action in the Table widget. To do this:

  1. Create a new script in the Data Panel of workspace.
  2. The first block (trigger) must be Manual start. Only scripts with this trigger can be used to run actions.
  3. Configure the expected fields. They will be filled in by the user or automatically when the action is launched from widget. In the block parameters:
    • Specify the field name
    • Select the data type (text, integer, date or date and time)
    • If a series of data is going to be received, check the Array box
    • You can make the field mandatory by using the Mandatory field switcher
    Configuring the expected field The action in the dashboard will not execute if the specified data type of the expected field does not match the actual data type.
  4. Click Continue. A modal window appears with the created fields. Fill them in and click Execute. The block will be tested and the date and time of execution, as well as the values entered in the fields, will appear in the left panel. Dialog box with the expected fields
  5. Add a block, for example to delete or update a table row.
  6. Select the table to be modified and map the fields using visual mapping. Field mapping
  7. Test the block and publish the script.
Note

If the script is not published, it will not appear when configuring buttons in the Actions tab in the Table widget.

Adding an Action to a Table

Actions are triggered in view mode via configured buttons above the Table. First, add a button, then assign actions to it.

Create or select the Table for which you want to configure an action. Open the Actions tab in the right-hand panel and click + Button.

Actions tab

After clicking, button configuration parameters appear. These are identical to those used in the Button widget.

Actions tab

Configuring the Action

To configure an action:

  1. In the button settings, click the Click action field.
  2. Click + Action.
  3. Select the script to be executed when the button is clicked in browse mode.

Action Configuration Parameters

  • Name — displayed on the button
  • Description — shown as a hint during script execution
  • Run the script — the dropdown list shows only scripts that return data
  • Parameters — configured individually for each field from the script. You can rename the field and must select an input method
  • Hint — text displayed on hover over the button in view mode (maximum length: 160 characters)
  • Activating the button — allows you to define a condition under which the button becomes clickable in view mode. The condition can be specified via formula or variable. Only Static list-type variables are available when using variable-based activation. If the condition’s value does not match the current variable value, the action button remains disabled in view mode. Additionally, you can select the button type (primary, secondary, or link) and configure the base border and text color
  • Hide inactive button — available for the Button widget
  • Auto update — triggered after script execution. You can refresh data in the widget from which the script was launched, in all widgets and placeholders on the view, or disable this option
Important

When configuring an activation condition via a formula that relies on data from a related table in the data model, the widget data may be filtered. Only rows with corresponding data in the related table will be displayed—this ensures the activation condition can be reliably evaluated against existing data.

Behavior in Browse Mode

A button with a single action becomes active when:

  • Required parameters are configured
  • Table rows are selected in browse mode (if required)
  • The activation condition is met

Clicking such a button either executes the action immediately or opens a modal window for parameter configuration.

If a button has multiple actions, it is enabled immediately. Clicking it opens a dropdown list of actions. List items corresponding to unconfigured actions are disabled.

Unavailable actions

If the Table is small, buttons above it may be collapsed into a single context-menu button.

Hint display logic:

  • If a hint is defined for the button or action, it appears on hover
  • If hints are defined for both the button and an action, the button’s hint takes precedence and is shown on hover

Configuring the Input Method

Note
  • For each action, the script parameter name and type are also displayed.
  • Parameter order can be changed by dragging and dropping. The change also appears in the action launch form.

Column

The script parameter receives a value from the table selected in the list.

Variable

Specifies a system variable or a dashboard variable (static or dynamic list). For this method, the variable must be exposed in a Parameter widget. The script receives the default or selected value from the Parameter. The value cannot be changed during action execution.

From Data Model

Allows using a list of tables or columns from the Data Model as parameter values. Selection occurs in the modal action launch window in Browse mode.

Tables list is the primary parameter, and Column list is dependent. To use Column list, you must first configure a parameter using Tables list.

Table list

When configuring Column list, you must specify the Linked parameter, which selects the table whose columns display. Only parameters using Tables list appear in the dropdown.

Column list

In Browse mode, the Column list parameter field becomes active only after a table is selected in the primary parameter.

Note

If the expected field in the script is an array, then when using the From Data Model input method for a table list parameter, only one table can be selected. However, multiple columns can be selected for the column list parameter.

Important

If the input method of primary parameter is changed, set to Column list, or deleted, the dependent parameter becomes unconfigured.

Formula

A formula allows configuring a dynamically changing parameter. When the Consider filters toggle is enabled, filters applied in Browse mode are applied to the list values. The parameter can also be hidden.

Set by Aggregation

A formula can pass an aggregation result to the expected field of script. The aggregation result must match the expected data type of field. In Browse mode, during action execution, the field using this input method is populated with the formula result. Upon script execution, the function result is passed to the expected field. If the expected field is an array, the function must return an array.

Note

When using Row filter, the value is calculated considering the selected rows.

Manual

During action execution, data is entered manually into the Default value field. Additionally, you can:

  • Add a description
  • Enable row filtering
  • Configure custom validation. To view the validation configuration tooltip, click the question mark icon next to the Validation field.
  • Hide the parameter (it will not appear in the action launch window)

Static List

A static list is created; during execution, the user selects a value from the list in the script launch window. The list can be defined using YAML. One or multiple default values can be entered or selected in the Default value field.

Dynamic List

A dynamic list is created; during execution, you can select a value from the list in the script launch window. Additionally, you can configure:

  • Display list
  • Default value
  • Row filter
  • Predefined filters (+ Filter button)
  • Switchers:
    • Hide parameter — the parameter does not appear in the action launch window
    • Entering any values — in Browse mode, a single value not present in the dynamic list can be entered and submitted. This switcher is hidden, if the expected script field is an array
    • Validation — available only when the Allow arbitrary values toggle is enabled. To view the validation configuration tooltip, click the question mark icon next to the Validation field.
    • Consider filters — data passed to the parameter respects filters applied in Browse mode

Action Execution

After configuring the action, a button appears above the table. It becomes active in Browse mode.

When all required parameters are configured, publish the dashboard.

To run the action, click the button. If the input method is Column or Set by formula, the button remains inactive until rows are selected. To select individual rows, check their checkboxes. Checking the column header selects all rows.

Note

Row selection is preserved separately for each page. Applying filters or sorting to table columns resets row selection.

Advice

If you accidentally click the script launch button, start another script while the launch loading animation is displayed. In this case, the launch window of the first script does not open.

The script launch window opens. Fill in the required fields and any others as needed. Click Run or press Enter to run the script. To cancel, click the close icon in the top-right corner.

Execution

Note

For non-required fields with a pre-filled value, you can clear it by clicking the close icon that appears on the right side of the field when hovering.

Important
  • If expected fields in the Manual start block are modified, the expected field name changes in the widget action settings, but the input method configuration remains unchanged.
  • The action applies only to the first 1 000 selected rows.
  • Script execution is available to users with read and/or edit access to the workspace and dashboard.

Action execution is not possible when:

  • The script is deleted
  • The Manual start trigger block in the script is replaced
  • The referenced table is removed from the Data Model
  • An empty value from a related table column is used. The column property must be changed to Nullable view and edit table

When the script runs, the message Action "Action name" started appears in the bottom-right corner. Upon successful completion, appears message Action completed. If execution fails, an error message is displayed. Depending on the error, you may navigate to the execution log, retry the script, or close the window.

Examples of Running Scripts from Dashboard

To perform any action, a script must be created.

Adding Row

To add a row to a table:

  1. Create a new script in the dashboard.
  2. Add a Manual start block. Add expected fields, specify data types, and click Continue. Use column names from tables in the Data Model. Test the block. Filled Manual start block
  3. Add an Insert rows block. Select the target table and map the columns to the expected fields defined in the first block. Use visual mapping for convenience. Test the block. Filled Insert rows block
  4. Publish the script.
  5. Open the dashboard containing the required table. Add an action in the Actions tab and provide it with a name. For each field’s parameters, specify the desired input method and column. To ensure the result is displayed after script execution, set the Auto update parameter to This widget. Add row script in table
  6. Publish the dashboard. Click Add row above the table. Enter the required parameters and click Run. Executing Add row script
  7. The row has been added. Row added

Removing Rows

To remove rows from a table:

  1. Create a new script in the dashboard.
  2. Add a Manual start block. Add an expected field, specify the data type, and click Continue. Use a column name from the Data Model table. Test the block. Manual start block in Remove rows script
  3. Add an SQL query block with a delete statement. Test the block. SQL query block for removal Example SQL query to remove a row:
    DELETE FROM tasks_table_1 WHERE incident_id = ${a1.Incident ID};
    
  4. Publish the script.
  5. Open the dashboard containing the required table. Add an action in the Actions tab and assign it a name. In the field’s parameters, select the Column input method and choose the same column that is referenced in the script’s SQL query. To display the result after script execution, set the Auto update parameter to This widget. Remove rows script in table
  6. Publish the dashboard. Select the rows to delete and click Remove rows above the table. Click Run. Removing rows from table
  7. The rows have been removed. Rows removed

Changing the Priority

To change priority:

  1. Create a new script in the dashboard.
  2. Add a Manual start block. Add expected fields, specify data types, and click Continue. Test the block. Manual start block in Change priority script
  3. Add an Update rows block. Specify the target table, key column, key value, and map the priority column. Use visual mapping for convenience. Test the block. Adding Update rows block
  4. Publish the script.
  5. Open the dashboard containing the required table. Add an action in the Actions tab and assign it a name. For each field’s parameters, specify the appropriate input method and column. To display the execution result after the script runs, set the Auto update parameter to This widget. Adding Change priority action
  6. Publish the dashboard. Select the rows for which to change priority. Click Change priority above the table. Enter or select the new value and click Run. Executing Change priority action
  7. Priority has been updated for the selected tasks. Priority changed

Custom Validation

Custom validation allows you to define your own conditions that input field values must satisfy when launching a script. Conditions are specified using ClickHouse syntax—for example, you can require a specific character count in a field, or define dependencies between parameter values, etc. To view the validation configuration tooltip, click the question mark icon next to the Validation field. The same tooltip is also available in the Formula Editor.

In the Formula Editor, a dedicated tab listing script parameters is available during validation setup. To include a parameter in the condition, simply click it—the correct syntax and escaping are applied automatically.

Example of Custom Validation Usage

Let’s consider how validation works using an example where only integer values are considered valid.

  1. A table with columns Product, Original price, and Comment is added to the view. Configure an action to add new rows. Custom validation example, step 1
  2. Create a new script in the workspace (named New row in this example). Add a Manual start block. Add expected fields Product, Unit price, and Comment. Test the block. Custom validation example, step 2
  3. Add an Insert rows block to the script. Select the target table and map columns to expected fields. Custom validation example, step 3
  4. Publish the script and return to the view. Select the table and add a new action. Select the previously created script. Custom validation example, step 4
  5. Configure parameters. Set the input method to Manual for all parameters.
  6. For the Unit price parameter, enter the following formula in the Validation field:
    if(NOT match($${Unit price}, '[0-9]'), 'Value must be an integer',
        null)
    
    This formula uses ClickHouse syntax. If any non-digit characters are entered in Unit price, the error message Value must be an integer appears below the field. Custom validation example, step 6
  7. Click Publish and test the script. Click the New row button above the table. In the modal window, fill in the fields. If an invalid value is entered in Unit price, an error appears. The Run button remains disabled until the data is corrected.

Script and Action Configuration in YAML

Configuration requires the actionButtons block. The tables below list the keys used within this block.

KeyTypeDefinition
namestringButton name
onClickClick action
hintstringHint for the button

Click Actions (onClick block)

The onClick block uses the following keys:

KeyTypeDefinition
typeenumClick action type. Only EXECUTE_SCRIPT is supported
namestringAction name
scriptKeystringScript key
parametersScript parameters (optional)
autoUpdateenumAuto update:

- NONE — none
- THIS_WIDGET — this widget
- ALL_WIDGETS — all widgets
descriptionstringDescription (optional)
buttonTypeenumButton type:

- primary — primary
- primary-outlined — secondary
- link — link
colorstringButton text color
backgroundColorstringButton background color
borderColorstringBorder color for secondary button
activateConditionButton activation

Parameter Configuration (parameters block)

The parameters block defines script parameters:

KeyTypeDefinition
namestringParameter name in the script
displayNamestringDisplay name
inputMethodenumInput method for the variable
isHiddenbooleanHide parameter
dbDataTypeenumData type of the column from the Data Model
hideInactiveButtonbooleanHide inactive button

Button Color Configuration (backgroundColor, borderColor, and color blocks)

When configuring the backgroundColor, color, or borderColor blocks, use the keys described below.

KeyTypeDefinition
modeenumColoring mode:

- AUTO — automatic
- BASE — solid
valuestringHEX color code (enclosed in double quotes)

Button Activation Condition (activateCondition block)

The activateCondition block defines button activation conditions:

KeyTypeDefinition
modeenumActivation mode:

- VARIABLE — by variable
- FORMULA — by formula
variableNamestringVariable name (double-quoted; applicable only for VARIABLE mode)
variableValuestringVariable value (double-quoted; applicable only for VARIABLE mode)
formulastringFormula (double-quoted; applicable only for FORMULA mode)
Input Method (inputMethod key)

The following input methods are available:

  • COLUMN — column
  • VARIABLE — variable
  • DATA_MODEL — from Data Model
  • FORMULA — formula
  • AGGREGATION — define by aggregation
  • MANUALLY — manual
  • STATIC_LIST — static list
  • DYNAMIC_LIST — dynamic list

Column (COLUMN) settings:

KeyTypeDefinition
tableNamestringTable name
columnNamestringColumn name from the table specified in tableName

Variable (VARIABLE) settings:

KeyTypeDefinition
sourceVariablestringVariable name

From Data Model (DATA_MODEL) settings:

KeyTypeDefinition
optionenumUsage option:
- TABLE_LIST — table list
- COLUMN_LIST — column list
parentstringName of the main parameter using TABLE_LIST. Applicable only for COLUMN_LIST

Formula (FORMULA) settings:

KeyTypeDefinition
formulastringFormula
filterByRowsbooleanCompute formula considering the filter on selected rows

Define by aggregation (AGGREGATION) settings:

KeyTypeDefinition
formulastringFormula (supports aggregate functions)
filterByRowsbooleanCompute formula considering the filter on selected rows

Manual (MANUALLY) settings:

KeyTypeDefinition
defaultValuestringDefault value
filterByRowsbooleanCompute formula considering the filter on selected rows
validationstringValidation
descriptionstringField description

Static list (STATIC_LIST) settings:

KeyTypeDefinition
optionsstringList of values
defaultOptionIndexnumber[]Default value index

Dynamic list (DYNAMIC_LIST) settings:

KeyTypeDefinition
optionsstringList (defined by formula)
displayOptionsstringDisplayed list (defined by formula)
insertAnyValuesbooleanAllow arbitrary values toggle. In view mode, a single value not present in the dynamic list can be entered and submitted.
validationstringValidation (applies only when insertAnyValues is enabled)
defaultValuestringDefault value (defined by formula)
filterByRowsbooleanCompute formula considering the filter on selected rows
filtersPredefined filters (optional)
considerFiltersbooleanApply filters from view mode

Example of actionButtons Block Usage

widgets:
  - key: table (1)
    apiVersion: "17"
    type: TABLE
    settings:
      actionButtons:
        - name: Rows
          onClick:
            - type: EXECUTE_SCRIPT
              name: Add Rows
              scriptKey: bf29c4de-8349-4e59-9e1b-f33c40bb1814
              parameters:
                - name: Product
                  inputMethod: COLUMN
                  columnName: Product
                  tableName: product_new
                  displayName: ""
                  isHidden: false
                  dbDataType: String
                - name: Unit Price
                  inputMethod: COLUMN
                  columnName: Unit Price
                  tableName: product_new
                  displayName: ""
                  isHidden: false
                  dbDataType: Float64
                - name: Comment
                  inputMethod: COLUMN
                  columnName: Comment
                  tableName: product_new
                  displayName: ""
                  isHidden: false
                  dbDataType: String
              autoUpdate: THIS_WIDGET
              description: ""
              activateCondition:
                formula: ""
                mode: FORMULA
          buttonType: primary
          color:
            mode: AUTO
          backgroundColor:
            mode: AUTO

Was the article helpful?

Yes
No
Previous
Variables
We use cookies to improve our website for you.