DeepSee Implementation Guide
Defining Custom Actions
[Back] [Next]
   
Server:docs1
Instance:LATEST
User:UnknownUser
 
-
Go to:
Search:    

This chapter describes how to define custom actions for use in DeepSee dashboards. It discusses the following topics:

Introduction
You define custom actions within KPI classes. Then:
For details on defining KPIs, see the Advanced DeepSee Modeling Guide.
You can perform many of the same operations with either a standard action or a custom action:
Operation Available As Standard Action? Can Be Performed in Custom Action?
Setting a filter Yes Yes
Setting a filter and refreshing the display Yes Yes
Refreshing the display of a widget Yes Yes
Refreshing the display of the entire dashboard Yes No
Specifying the row or column sort for a pivot table Yes No
Specifying the row or column count for a pivot table Yes No
Displaying a listing for a pivot table Yes No
Displaying another dashboard Yes Yes
Displaying a URL in the same page Yes Yes
Displaying a URL in a new page No Yes
Executing code on the server No Yes
Changing the data source of the widget Yes No
Changing the row or column specification of the widget Yes No
For details on the standard actions, see Adding Widget Controls in Creating DeepSee Dashboards.
Context Information
DeepSee makes context information available to actions, by two different mechanisms. When a user launches a custom action, DeepSee writes context information into the pContext variable, which is available in your custom code on the server. When a custom action opens a URL, DeepSee replaces the $$$VALUELIST and $$$CURRVALUE tokens, if these are included in the URL. The following figure illustrates these mechanisms:
Defining the Behavior of Actions
To define custom actions, you must both declare the actions and define their behavior.
Declaring Actions
To declare actions, do either or both of the following tasks in a KPI class:
Defining the Behavior of the Actions
To define the behavior of the actions, override the %OnDashboardAction() callback method of your KPI class. This method has the following signature:
classmethod %OnDashboardAction(pAction As %String, pContext As %ZEN.proxyObject) as %Status
DeepSee executes this callback when a user invokes an action on a dashboard. pAction is the logical name of the action. pContext is an object that contains information about the currently selected scorecard row and that provides a way for the method to return commands to the dashboard; the next sections give the details.
A simple example is as follows:
ClassMethod %OnDashboardAction(pAction As %String, pContext As %ZEN.proxyObject) As %Status
{
 Set sc = $$$OK
 Try {
      If (pAction = "Action 1") {
              //this part defines Action 1
              //perform server-side actions
          }
         Elseif (pAction="Action 2")
         {
                //this part defines Action 2
                //perform other server-side actions
                 }
        }
        Catch(ex) {
                Set sc = ex.AsStatus()
        }
 Quit sc
}
This method defines two actions, Action 1 and Action 2.
Note:
Because %OnDashboardAction() is a class method, you do not have access to %seriesNames or other properties of the KPI class from within this method (no class instance is available from the method).
Available Context Information
An action can use context information — values from the dashboard, based on the row or rows that the user selected before launching the action. These values are useful if you want to cause changes in the database that are dependent on context.
Because %OnDashboardAction() is a class method, you do not have access to %seriesNames or other properties of the KPI class from within this method. Instead, DeepSee provides the pContext variable, which is an object whose properties provide information for use in the action. The details are different in the following scenarios:
Scenario: Pivot Table Widget with Pivot Table as Data Source
In this scenario, within the %OnDashboardAction() method, the pContext variable has the following properties:
Property Name Property Contents
currValue Value of first selected cell
currSeriesNo Column number
currItemNo Row number
currFilterSpec MDX %FILTER clause or clauses that represent the filtering applied to the current cell context. This includes values of any filter controls, as well as the row and column context.
valueList Null
cubeName Name of the cube queried by this pivot table
mdx MDX query defined by this pivot table.
pivotVariables A proxy object that contains one property for each pivot variable. Specifically, pContext.pivotVariables.varname contains the value of the pivot variable varname. In this proxy object, all pivot variable names are in lowercase. For example, if the server defines a pivot variable named MyVar, this pivot variable is available as pContext.pivotVariables.myvar
filters An array that indicates the current values of all filter controls. For each node in this array, the subscript is the name of a filter defined by the KPI. The value of the node is the corresponding key or keys, in the form described at Allowed Default Values for Filters.
Scenario: Pivot Table Widget with Listing as Data Source
In this scenario, within the %OnDashboardAction() method, the pContext variable has the following properties:
Property Name Property Contents
currValue Value of the first selected cell that was displayed before the listing was shown
currSeriesNo Column number of the first selected cell that was displayed before the listing was shown
valueList Comma-separated list of values from the first column of the listing (these values must not contain commas)
pivotVariables A proxy object that contains one property for each pivot variable. Specifically, pContext.pivotVariables.varname contains the value of the pivot variable varname. In this proxy object, all pivot variable names are in lowercase. For example, if the server defines a pivot variable named MyVar, this pivot variable is available as pContext.pivotVariables.myvar
filters An array that indicates the current values of all filter controls. For each node in this array, the subscript is the name of a filter defined by the KPI. The value of the node is the corresponding key or keys, in the form described at Allowed Default Values for Filters.
Scenario: Pivot Table Widget with KPI as Data Source
In this scenario, within the %OnDashboardAction() method, the pContext variable has the following properties:
Property Name Property Contents
currValue Value of first selected cell
currSeriesNo Column number of first selected cell
valueList Null
pivotVariables A proxy object that contains one property for each pivot variable. Specifically, pContext.pivotVariables.varname contains the value of the pivot variable varname. In this proxy object, all pivot variable names are in lowercase. For example, if the server defines a pivot variable named MyVar, this pivot variable is available as pContext.pivotVariables.myvar
filters An array that indicates the current values of all filter controls. For each node in this array, the subscript is the name of a filter defined by the KPI. The value of the node is the corresponding key or keys, in the form described at Allowed Default Values for Filters.
Scenario: Scorecard with KPI as Data Source
In this scenario, within the %OnDashboardAction() method, the pContext variable has the following properties:
Property Name Property Contents
currValue Value of the KPI property that is marked as Value Column in this scorecard
currSeriesNo Row number
valueList Value of the KPI property that is marked as Value Column in this scorecard
pivotVariables A proxy object that contains one property for each pivot variable. Specifically, pContext.pivotVariables.varname contains the value of the pivot variable varname. In this proxy object, all pivot variable names are in lowercase. For example, if the server defines a pivot variable named MyVar, this pivot variable is available as pContext.pivotVariables.myvar
filters An array that indicates the current values of all filter controls. For each node in this array, the subscript is the name of a filter defined by the KPI. The value of the node is the corresponding key or keys, in the form described at Allowed Default Values for Filters.
Executing Client-Side Commands
An action can contain commands to execute when the control returns to the dashboard. To include such commands, set the pContext.command property within the definition of the action. For example:
        //this part defines Action 1
        //perform server-side actions
        //on returning, refresh the widget that is using this KPI 
        Set pContext.command="refresh;"
For pContext.command, specify a string of the following form to execute a single command:
command1
For pContext.command, specify a semicolon-delimited list of commands:
command1;command2;command3;...;
The final semicolon is optional.
Some commands accept one or more arguments. For these, use command:arg1:arg2:... instead of command.
Available Commands
Within pContext.command, you can use the following commands:
alert
alert:message
Displays the message in a dialog box. message is the message to display
For example:
 Set pContext.command = "alert:hello world!"
applyFilter
applyFilter:target:filterSpec
For information on the arguments, see Details for applyFilter and setFilter.”
This command sets the given filter and refreshes the browser window.
For example, the following applies a filter to a pivot table:
 Set pContext.command = "applyFilter:samplepivot:[DateOfSale].[Actual].[YearSold]:&[2008]"
navigate
navigate:url
Where url is the URL to display.
This command opens the given URL in the same browser window.
For example:
 Set pContext.command = "navigate:http://www.google.com"
newWindow
newWindow:url
Where url is the URL to display.
This command opens the given URL in a new browser window.
For example:
 Set pContext.command = "newWindow:http://www.google.com"
popup
popup:zenpopupurl
Where zenpopupurl is the relative URL of a Zen popup window.
This command displays the given Zen popup window. For example:
 Set pContext.command = "popup:%ZEN.Dialog.fileSelect.cls"
refresh
refresh:widgetname
Where widgetname is the optional name of a widget to refresh; if you omit this argument, the command refreshes the widget from which the user launched the action.
This refreshes the browser window, using any current settings for filters.
For example:
 // Refresh the widget that fired this action and another named samplepivot.
 Set pContext.command = "refresh;refresh:samplepivot"
Note that this example includes multiple commands, separated by a semicolon.
setFilter
setFilter:target:filterSpec
For information on the arguments, see Details for applyFilter and setFilter.”
This command sets the given filter, but does not refresh the browser window.
Details for applyFilter and setFilter
The applyFilter and setFilter commands are as follows, respectively:
applyFilter:target:filterSpec
And:
setFilter:target:filterSpec
Where:
Displaying a Different Dashboard
In your custom action, you can use navigate or newWindow to display a different dashboard. Use the dashboard URL as described in the chapter Accessing Dashboards from Your Application.” The URL can include the SETTINGS keyword, which initializes the state of the dashboard.
Generating a SQL Table from Cube Context
In your custom action, you can use the %CreateTable API to create a SQL table from cube context. The table may be created from either:
  1. A field list
  2. The name of a listing defined in the cube, either as a field list or a custom SQL query.
See the class reference for more details.