Running a Script from a Dashboard
- Running a Script from a Dashboard
- Configuring a Script
- Configuring an Action
- Action Configuration Parameters
- Configuring the Input Method
- Action Execution
- Examples of Running Scripts from Dashboard
- Adding Row
- Script and Action Settings in YAML
- Script Parameters (parameters block)
- Configuring the Button Color
- Activating the Button (blockingCondition block)
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:
- Create a new script in the Data Panel of workspace.
- The first block (trigger) must be Manual start. Only scripts with this trigger can be used to run actions.
- 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
- 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.
- Add a block, for example to delete or update a table row.
- Select the table to be modified and map the fields using visual mapping.
- Test the block and publish the script.
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.
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
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
- 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.
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.
In Browse mode, the Column list parameter field becomes active only after a table is selected in the primary parameter.
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.
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.
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.
Row selection is preserved separately for each page. Applying filters or sorting to table columns resets row selection.
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.
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.
- 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:
- Create a new script in the dashboard.
- 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.
- 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.
- Publish the script.
- 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.
- Publish the dashboard. Click Add row above the table. Enter the required parameters and click Run.
- The row has been added.
Removing Rows
To remove rows from a table:
- Create a new script in the dashboard.
- 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.
- Add an SQL query block with a delete statement. Test the block.
Example SQL query to remove a row:
DELETE FROM tasks_table_1 WHERE incident_id = ${a1.Incident ID}; - Publish the script.
- 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.
- Publish the dashboard. Select the rows to delete and click Remove rows above the table. Click Run.
- The rows have been removed.
Changing the Priority
To change priority:
- Create a new script in the dashboard.
- Add a Manual start block. Add expected fields, specify data types, and click Continue. Test the block.
- 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.
- Publish the script.
- 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.
- 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.
- Priority has been updated for the selected tasks.
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.
- A table with columns Product, Original price, and Comment is added to the view. Configure an action to add new rows.
- 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.
- Add an Insert rows block to the script. Select the target table and map columns to expected fields.
- Publish the script and return to the view. Select the table and add a new action. Select the previously created script.
- Configure parameters. Set the input method to Manual for all parameters.
- For the Unit price parameter, enter the following formula in the Validation field:
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.
if(NOT match($${Unit price}, '[0-9]'), 'Value must be an integer', null) - 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.
| Key | Type | Definition |
|---|---|---|
| name | string | Action name |
| type | enum | Click action type: EXECUTE_SCRIPTOnly one action type is allowed |
| description | string | Description (optional) |
| filters | — | Predefined filters (optional) |
| scriptKey | string | Script key |
| parameters | — | Script parameters (optional) |
| autoUpdate | enum | Auto update: - NONE — none- THIS_WIDGET — this widget- ALL_WIDGETS — all widgets |
| buttonType | enum | Button type: - primary — primary- primary-outlined — secondary- link — link |
| color | string | Button text color |
| backgroundColor | string | Button background color |
| borderColor | string | Border color for secondary button |
| blockingCondition | — | Activating the button |
Script Parameters (parameters block)
The parameters block defines script parameters:
| Key | Type | Definition |
|---|---|---|
| name | string | Parameter name in the script |
| displayName | string | Display name |
| inputMethod | enum | Variable input method |
| isHidden | boolean | Hide parameter |
| activateCondition | enum | Activating the button |
| hideInactiveButton | boolean | Hide inactive button |
Button Activation (activateCondition block)
| Key | Type | Definition |
|---|---|---|
| mode | enum | Activation mode: - VARIABLE — by variable- FORMULA — by formula |
| variableName | string | Variable name (in double quotes "") |
| variableValue | string | Variable value (in double quotes "") |
| formula | string | Formula (in double quotes "") |
Input Method (inputMethod key)
Available input methods:
COLUMN— columnVARIABLE— variableDATA_MODEL— from Data ModelFORMULA— set by formulaAGGREGATION— set by aggregationMANUALLY— enter manuallySTATIC_LIST— static listDYNAMIC_LIST— dynamic list
Column (COLUMN) settings:
| Key | Type | Definition |
|---|---|---|
| tableName | string | Table name |
| columnName | string | Column name from the table specified in tableName |
Variable (VARIABLE) settings:
| Key | Type | Definition |
|---|---|---|
| sourceVariable | string | Variable name |
From Data Model (DATA_MODEL) settings:
| Key | Type | Definition |
|---|---|---|
| option | enum | Usage option: - TABLE_LIST — table list- COLUMN_LIST — column list |
| parent | string | Name of the primary parameter using TABLE_LIST. Only for COLUMN_LIST |
Set by formula (FORMULA) settings:
| Key | Type | Definition |
|---|---|---|
| formula | string | Formula |
| filterByRows | boolean | Calculate formula considering row filter |
Set by aggregation (AGGREGATION) settings:
| Key | Type | Definition |
|---|---|---|
| formula | string | Formula supporting aggregate functions |
| filterByRows | boolean | Calculate formula considering row filter |
Manual (MANUALLY) settings:
| Key | Type | Definition |
|---|---|---|
| defaultValue | string | Default value |
| filterByRows | boolean | Calculate formula considering row filter |
| validation | string | Validation |
| description | string | Field description |
Static list (STATIC_LIST) settings:
| Key | Type | Definition |
|---|---|---|
| options | string | List of values |
| defaultOptionIndex | number[] | Default value |
Dynamic list (DYNAMIC_LIST) settings:
| Key | Type | Definition |
|---|---|---|
| options | string | List (defined by formula) |
| displayOptions | string | Display list (defined by formula) |
| insertAnyValues | boolean | Entering any values toggle. In Browse mode, a single value not in the dynamic list can be entered and submitted |
| validation | string | Validation (only if insertAnyValues is used) |
| defaultValue | string | Default value (defined by formula) |
| filterByRows | boolean | Calculate formula considering row filter |
| filters | — | Predefined filters (optional) |
| considerFilters | boolean | Consider filters from Browse mode |
Configuring the Button Color
When configuring backgroundColor, color, or borderColor, use the keys described below.
| Key | Type | Definition |
|---|---|---|
| mode | enum | Coloring mode: - AUTO — auto- BASE — solid |
| value | string | HEX color code (in double quotes) |
Activating the Button (blockingCondition block)
| Key | Type | Definition |
|---|---|---|
| mode | enum | Activating the button mode: - VARIABLE — by variable- FORMULA — by formula |
| variableName | string | Variable name (in double quotes, for VARIABLE mode only) |
| variableValue | string | Variable value (in double quotes, for VARIABLE mode only) |
| formula | string | Formula (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?