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 (mandatory): Use value RunScript to run a script.
  • label (mandatory): Text visible in the context menu item.
  • icon: Google Material icon visible in the context menu item.
  • projectName: Name of the project where the script is located. If not defined, the script is assumed to be found in the project where the dashboard is located.
  • scriptName: Name of the run script.
  • scriptId: Id of the run script. When defined, the projectName and scriptName parameters are ignored.
  • multiselect: Whether the script run is available when multiple rows are selected (true) or only when one row is selected (false). Default is true.
  • completedMessageHeader: Header text of the popup dialog shown when the action is successfully completed.
  • errorMessageHeader: Header text of the popup dialog shown when the action fails.
  • parameters: Object of additional parameters for the script. The parameters are available as a dictionary in the script.

The type and label are mandatory, and either the scriptName or scriptId is mandatory.

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": "Show details",
    "icon": "smart_toy",
    "scriptName": "Snow row details",
    "parameters": {
      "param1": "val1",
      "param2": 2.3
    }
  },
  {
    "type": "RunScript",
    "label": "Create ticket",
    "icon": "smart_toy",
    "projectName": "My project",
    "scriptName": "Create ticket to external system",
    "completedMessageHeader": "Ticket has been created",
    "errorMessageHeader": "Creating ticket failed",
    "multiselect": true
  },
  {
    "type": "RunScript",
    "label": "Get data",
    "icon": "smart_toy",
    "scriptId": 1
  }
]

Example scripts