Actions to Run Script in Table

From QPR ProcessAnalyzer Wiki
Revision as of 23:28, 25 February 2024 by Ollvihe (talk | contribs) (→‎Examples)
Jump to navigation Jump to search

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

5. Following action parameters are supported: 1.1 label: Text visible in the context menu item. 1.2 icon: Google Material icon visible in the context menu item. 1.3 completedMessageHeader: Header of the popup dialog shown when the action is successfully completed. 1.4 errorMessageHeader: Header of the popup dialog shown when the action fails. 1.5 multiselect: Whether the action is available when multiple rows are selected (true) or only when one row is selected (false). Default is true. 5.1 projectName: Name of the project where the script is located. 5.2 scriptName: Name of the script. 5.2.1 If the projectName parameter is defined, the script is searched from that project. 5.2.2 If the projectName parameter is not defined, the script is search from the project where the dashboard is located. 5.3 scriptId: Id of the script. 5.3.1 When defined, the projectName and scriptName parameters are ignored. 5.4 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
    }
  }]

Example scripts