Skip to main content
Previous section   Next section

Defining the Behavior of Actions

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:

  • Within the <kpi> element, include one <action> element for each action.

    This element specifies the name of an action available within this KPI class; the user interfaces use this information to create lists of available actions for the users. For example:

    <kpi xmlns="http://www.intersystems.com/deepsee/kpi"
     name="Holefoods Actions">
    
    <action name="ActionA"/>
    <action name="ActionB"/>
    <action name="ActionC"/>
    </kpi>

    For information on <action>, see the appendix “Reference Information for KPI and Plug-in Classes” in Advanced Modeling for InterSystems Business Intelligence.

  • Override the %OnGetActionList() callback method of your KPI class. This method has the following signature:

    ClassMethod %OnGetActionList(ByRef pActions As %List, pDataSourceName As %String = "") As %Status

    Where pActions is an array with the following nodes:

    Node Value
    pActions Number of actions
    pActions(n) Details for the nth action. This is a $LISTBUILD list that consists of the following items:
    • A string that equals the logical action name
    • A string that equals the corresponding display name

    And pDataSourceName is for future use.

    For example:

    ClassMethod %OnGetActionList(ByRef pActions As %List, pDataSourceName As %String = "") As %Status
    {
        set newaction=$LB("New Action","New Action Display Name")
        set pActions($I(pFilters))=newaction
        quit $$$OK
    }

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

The system 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).

Previous section   Next section