Introduction to Action Events

Action Events can be grouped into two general categories: Local and Global events.

This article explains how to create Local and Global action events, describes the ways in which action events can interact with the Exago application, and lays out examples for common usages.

Creating Event Handlers

Action event handlers are created using the Admin Console or by directly editing the WebReports.xml config file. They can also be added or modified on a per-session basis in a .NET configuration using the 'Api.SetupData.ActionEvents' server call.

The Action Events tab will open and display the selected event or a New Action Event dialog:

Each Event Handler has the following properties:

Writing Action Events

When an Action Event is fired, two primary parameter objects are passed: sessionInfo and clientInfo. These are the main points of interaction with the Exago application.

arguments array – The server-side portion of action events can also access an array of input values called args. These parameters are passed manually from client code to server code using the function clientInfo.ServerCallback(eventName, args...).

JavaScript

Note: This is only available in Windows environments.

Both the server-side and client-side code for action events can be written in JavaScript. The client side code must still be passed to the sessionInfo.JavascriptAction object as a string. This can be done by calling toString() on a function, then concatenating the invocation operator, before passing it to the JavascriptAction.JsCode. This can be an easier way to write client scripts since the code is written natively, instead of as a string literal. However, note that writing server code in JS means that it cannot access any C#, .NET, or CLR libraries.

jslang.png

Selecting JavaScript from the Custom Code window

Example of writing client-side JS in the Custom Code window

// this function wraps the client-side code
function debug() {
    debugger;
}

/* any other server-side processing can be done in JS */

// call Function.toString() on the client-side function, then concatenate
// the "invoke" operator (), before passing it to the JavascriptAction
var jscode = "(" + debug.toString() + "());";
sessionInfo.JavascriptAction.SetJsCode(jscode);
return sessionInfo.JavascriptAction;
Note: The clientInfo object is only accessible from within the client code, not on the server. However, it could be passed to the server in a callback as JSON using clientInfo.ServerCallback("eventName", JSON.stringify(clientInfo));. This will require either two separate action events - one to send the object, and one to receive it - or one with some conditional logic to handle both cases.