Actions to Run Script in Table: Difference between revisions

From QPR ProcessAnalyzer Wiki
Jump to navigation Jump to search
Line 7: Line 7:
== Action settings ==
== Action settings ==
Following action settings are available:
Following action settings are available:
* '''type''': Use value '''RunScript''' to run a script.
* '''type''' (mandatory): Use value '''RunScript''' to run a script.
* '''label''': Text visible in the context menu item.
* '''label''' (mandatory): Text visible in the context menu item.
* '''icon''': Google Material icon 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.
* '''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.
* '''errorMessageHeader''': Header of the popup dialog shown when the action fails.
* '''scriptName''': Name of the run script.
* '''multiselect''': Whether the action is available when multiple rows are selected (true) or only when one row is selected (false). Default is true.
* '''scriptId''': Id of the run script. When defined, the projectName and scriptName parameters are ignored.
* '''projectName''': Name of the project where the script is located.
* '''multiselect''': Whether the script run is available when multiple rows are selected (''true'') or only when one row is selected (''false''). Default is ''true''.
* '''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.
* '''completedMessageHeader''': Header text of the popup dialog shown when the action is successfully completed.
* '''scriptId: Id of the script. When defined, the projectName and scriptName parameters are ignored.
* '''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.
* '''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 ==
== Passed parameters ==

Revision as of 00:10, 26 February 2024

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