Actions to Run Script in Table

From QPR ProcessAnalyzer Wiki
Jump to navigation Jump to search

Overview

The actions to run scripts are available in the data grid context menu. Loading animation for the data grid is shown during the operation.

When the operation completes successfully or fails, a popup message is shown. The return value of the script is shown as a popup message. If the script throws a user-defined exception, the thrown value is shown as popup message (stacktrace is not shown). 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:

  • type: Use value RunScript to run a script.
  • 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
    }
  }]

Example scripts