Actions to Run Script in Table
Overview
Chart actions are available in the data grid context menu. 2. Loading animation for the data grid is shown during the operation. 3. When the operation completes successfully or fails, a popup message is shown. +4. All actions support parameters listed in #71802#. 5. Following types of actions are available: 5.1 End tasks: Can be used when data grid is showing tasks. The selected tasks are ended (#71800#). +5.2 Run script: Runs the defined script and shows return value as popup dialog (#71798#).
1. When action type is "RunScript", the action will run the defined script. 2. The return value of the script is shown as a popup message. 3. If the script throws a user-defined exception, the thrown value is shown as popup message (stacktrace is not shown). 4. If the script throws other than user-defined exception, the error message and stacktrace is shown as popup message.
Action settings
Following action settings are available:
- label: Text visible in the context menu item.
- icon: Google Material icon visible in the context menu item.
- completedMessageHeader: Header of the popup dialog shown when the action is successfully completed.
- errorMessageHeader: Header of the popup dialog shown when the action fails.
- multiselect: Whether the action is available when multiple rows are selected (true) or only when one row is selected (false). Default is true.
- projectName: Name of the project where the script is located.
- scriptName: Name of the script. If the projectName parameter is defined, the script is searched from that project. If the projectName parameter is not defined, the script is search from the project where the dashboard is located.
- scriptId: Id of the script. When defined, the projectName and scriptName parameters are ignored.
- parameters: Object of additional parameters for the script. The parameters are available as a dictionary in the script.
Passed parameters
Following parameters are passed to the script and are available as variables in the script:
- selectedData: Dictionary of arrays containing the selected rows data for each column. The data is available as following keys:
- Column header labels (the ones that are visible in the table)
- Column technical names (dimension0, dimension1, ... measure0, measures2, ...).
- Column indices (0, 1, 2, ...)
- rowIndices: Array of selected row indices (first row is zero).
- variables: Dictionary of dashboard variables.
- action: Dictionary containing settings of the clicked action. (This is the way to access the action parameters.)
- query: Dictionary containing the query made by the chart.
- chartSettings: Dictionary containing the chart settings.
Example action settings
[{ "type": "RunScript", "label": "Run my action 1", "scriptName": "My action 1", "parameters": { "param1": "val1", "param2": 2.3 } }, { "type": "RunScript", "label": "Run my action 2", "projectName": "${projectName}", "scriptName": "My action 2", "completedMessageHeader": "Operation completed", "errorMessageHeader": "<span>Custom error occurred</span>", "icon": "cancel", "multiselect": true }, { "type": "RunScript", "label": "<span>Nonexisting action</span>", "icon": "smart_toy", "multiselect": false, "scriptId": 123456789, "parameters": { "param1": "val1", "param2": 2.3 } }]