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

Running a Script from a Dashboard

In this article

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.

This functionality allows to:

  • Add, delete or update table rows
  • Perform an action in another system:
    • Create an issue
    • Increase the priority of an issue
    • Send a message

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 in the configurations of the action in the Table widget.

Configuring an Action

To configure an action, go to the dashboard, create or select the table where you want to configure the action, and open the Actions tab in the right panel. Click + Action.

Actions tab

After clicking, parameters for action configuration appear.

Action Configuration Parameters

  • Name — displayed on the button
  • Description — shown as a hint during script execution
  • Execute script — the dropdown list shows only scripts that return data
  • Parameters — appears after selecting a script. Each field from the script is a separate parameter, for which you can change the display name and must configure the input method
  • Auto update — triggers after script completion. You can refresh data in the widget from which the script was launched, in all widgets and placeholders of the view, or disable the option
  • Activating the button — allows defining a condition under which the button becomes clickable in Browse mode. The condition can be specified via formula or variable. If variable-based activation is selected, only Static list variables are available. If the condition value does not match the current variable value, the action button remains inactive in Browse mode. Additionally, you can select the button type: primary, secondary, or link. You can also configure the border and text color of button.
  • Hide inactive button — available for the Button widget
Important

When configuring an action activation condition using a formula based on data from a related table in the Data Model, data in the widget with the action 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.

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
  • 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 if Entering any values switcher is enabled
    • 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.

Execution

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.

Fields

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 with the target table. Add an action in the Buttons tab and name it. For each field parameter, specify the input method and column. To reflect results after execution, set Auto update 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 with the target table. Add an action in the Actions tab and name it. Set the field parameter input method to Column and select the same column used in the SQL query of script. To reflect results after execution, set Auto update 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 with the needed table. Add an action in the Actions tab and name it. For each field parameter, specify the input method and column. To reflect results after execution, set parameter Auto update 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 defining conditions that input field values must satisfy during script execution. For example, you can require a specific number of characters or make one value dependent of parameter on another.

Below is an example where only integer values are accepted.

  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 Settings in YAML

Table click actions are configured in the actions block. The table below lists available keys.

KeyTypeDefinition
namestringAction name
typeenumClick action type: EXECUTE_SCRIPT
Only one action type is allowed
descriptionstringDescription (optional)
filtersPredefined filters (optional)
scriptKeystringScript key
parametersScript parameters (optional)
autoUpdateenumAuto update:

- NONE — none
- THIS_WIDGET — this widget
- ALL_WIDGETS — all widgets
buttonTypeenumButton type:

- primary — primary
- primary-outlined — secondary
- link — link
colorstringButton text color
backgroundColorstringButton background color
borderColorstringBorder color for secondary button
blockingConditionActivating the button

Script Parameters (parameters block)

The parameters block defines script parameters:

KeyTypeDefinition
namestringParameter name in the script
displayNamestringDisplay name
inputMethodenumVariable input method
isHiddenbooleanHide parameter
activateConditionenumActivating the button
hideInactiveButtonbooleanHide inactive button

Button Activation (activateCondition block)

KeyTypeDefinition
modeenumActivation mode:

- VARIABLE — by variable
- FORMULA — by formula
variableNamestringVariable name (in double quotes "")
variableValuestringVariable value (in double quotes "")
formulastringFormula (in double quotes "")

Input Method (inputMethod key)

Available input methods:

  • COLUMN — column
  • VARIABLE — variable
  • DATA_MODEL — from Data Model
  • FORMULA — set by formula
  • AGGREGATION — set by aggregation
  • MANUALLY — enter manually
  • 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 primary parameter using TABLE_LIST. Only for COLUMN_LIST

Set by formula (FORMULA) settings:

KeyTypeDefinition
formulastringFormula
filterByRowsbooleanCalculate formula considering row filter

Set by aggregation (AGGREGATION) settings:

KeyTypeDefinition
formulastringFormula supporting aggregate functions
filterByRowsbooleanCalculate formula considering row filter

Manual (MANUALLY) settings:

KeyTypeDefinition
defaultValuestringDefault value
filterByRowsbooleanCalculate formula considering row filter
validationstringValidation
descriptionstringField description

Static list (STATIC_LIST) settings:

KeyTypeDefinition
optionsstringList of values
defaultOptionIndexnumber[]Default value

Dynamic list (DYNAMIC_LIST) settings:

KeyTypeDefinition
optionsstringList (defined by formula)
displayOptionsstringDisplay list (defined by formula)
insertAnyValuesbooleanEntering any values toggle. In Browse mode, a single value not in the dynamic list can be entered and submitted
validationstringValidation (only if insertAnyValues is used)
defaultValuestringDefault value (defined by formula)
filterByRowsbooleanCalculate formula considering row filter
filtersPredefined filters (optional)
considerFiltersbooleanConsider filters from Browse mode

Configuring the Button Color

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

KeyTypeDefinition
modeenumColoring mode:

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

Activating the Button (blockingCondition block)

KeyTypeDefinition
modeenumActivating the button mode:

- VARIABLE — by variable
- FORMULA — by formula
variableNamestringVariable name (in double quotes, for VARIABLE mode only)
variableValuestringVariable value (in double quotes, for VARIABLE mode only)
formulastringFormula (in double quotes, for FORMULA mode only)

Example:

actions:
  - name: "Action"
    type: EXECUTE_SCRIPT
    description: "Action description"
    filters:
      - name: case_id
        formula: '"case_table"."case_id"'
        dbDataType: STRING
        format: STRING
        filteringMethod: INCLUDE
        checkedvalues: 
          - 'Value_1'
          - 'Value_2'
          - 'Value_3'
        formValues: {}
    scriptName: script_1
    parameters: 
      - name: parameter_1
        displayName: "Parameter 1"
        inputMethod: COLUMN
        tableName: table_1
        columnName: column_1
        isHidden: false
      - name: parameter_2
        displayName: "Parameter 2"
        inputMethod: VARIABLE
        sourceVariable: variable_1
        isHidden: false
      - name: parameter_3
        displayName: "Parameter 3"
        inputMethod: FORMULA
        formula: 'avg("table_1"."column_1")'
        isHidden: false
      - name: parameter_4
        displayName: "Parameter 4"
        inputMethod: MANUALLY
        description: "Parameter field description"
        isHidden: false
      - name: parameter_5
        displayName: "Parameter 5"
        inputMethod: STATIC_LIST
        options:
          - '10'
          - '20'
          - '30'
        defaultOptionIndex: 0
        isHidden: false
      - name: parameter_6
        displayName: "Parameter 6"
        inputMethod: DYNAMIC_LIST
        formula: '"table_1"."column_1"'
        dbDataType: STRING
        filters:
          - name: case_id
            formula: '"case_table"."case_id"'
            dbDataType: STRING
            format: STRING
            filteringMethod: INCLUDE
            checkedvalues: 
              - 'Value_1'
              - 'Value_2'
              - 'Value_3'
            formValues: {}
        defaultValue: '100'
        isHidden: false
    updateDashboard: true

Was the article helpful?

Yes
No
Previous
Dimensions and Measures
We use cookies to improve our website for you.