Learning
Community
Open Exchange
Global Masters
InterSystems IRIS Data Platform 2019.4 / Analytics / Implementing InterSystems IRIS Business Intelligence / Other Development Work
Previous section   Next section

Other Development Work

Depending on the users’ needs and the business requirements, you may have to do some or all of the following additional development work:
Also see “Accessing the Samples Shown in This Book,” in the first chapter.

Adding Paper Sizes

When users print a dashboard widget to a PDF file, the system provides a default set of paper sizes, and the user can choose among them. To extend this set of sizes, add nodes as needed to the ^DeepSee.PaperSizes global, as follows:
Node Value
^DeepSee.PaperSizes(n) where n is an integer
$LISTBUILD(sizename,dimensions) where sizename is the name of the size and dimensions specifies the dimensions. dimensions must have one of the following forms:
widthxheight in
widthxheight mm
There must be exactly one space between height and the unit name.
For example:
Set ^DeepSee.PaperSizes(1) = $LB("My Sticker","100x100 mm")
The new size is immediately available.

Auditing User Activity

You can execute custom code, such as writing to an audit log, every time a user executes a query or accesses a dashboard.
To add custom code to execute when users execute a query, perform the following one-time setup steps:
  • Write a class method, routine, or subroutine that contains the custom code. The first subsection provides details on the requirements and options; the second subsection provides an example.
  • Set ^DeepSee.AuditQueryCode equal to a string containing a valid ObjectScript statement that executes that method, routine, or subroutine.
    For example, do the following in the Terminal:
    set ^DeepSee.AuditCode="do ^MyBIAuditCode"
    
    Every time a query is executed in this namespace, the system executes the code specified in ^DeepSee.AuditQueryCode, thus invoking your routine or class method.
Similarly, to add custom code to execute when users access a dashboard:
  • Write a class method, routine, or subroutine that contains the custom code.
  • Set ^DeepSee.AuditCode equal to a string containing a valid ObjectScript statement that executes that method, routine, or subroutine.
    Every time a dashboard is accessed in this namespace, the system executes the code specified in ^DeepSee.AuditCode.

Audit Code Requirements and Options

When you define audit code for either scenario, make sure that the code does not write any output to the current device. Also make sure that it does not kill any % variables required by InterSystems IRIS®.
Your code can use the following variables:
  • $USERNAME — name of the current user.
  • $ROLES — roles of the current user.
  • %dsQueryText — text of the current query.
  • %dsCubeName — logical name of the cube used in the current query.
  • %dsResultSet — current instance of %DeepSee.ResultSet, which you can use to access other information, if needed. For details on working with %DeepSee.ResultSet, see “Executing Business Intelligence Queries Programmatically,” earlier in this book.
  • %dsDashboard — name of the dashboard that is being accessed, if any.
Typically, audit code writes output to a file or to a global.
Note that %dsQueryText, %dsCubeName, and %dsResultSet are only available to audit routines using ^DeepSee.AuditQueryCode, while %dsDashboard is only available to routines using ^DeepSee.AuditCode.

Example

The following shows a simple example audit routine. It has one subroutine for use with ^DeepSee.AuditQueryCode and another subroutine for use with ^DeepSee.AuditCode:
 ; this is the routine DeepSeeAudit
 quit
 
dashboard 
 set auditentry="At "_$ZDT($H,3)_", " _$USERNAME_" accessed dashboard: "_%dsDashboard
 set ^MyBIAuditLog($INCREMENT(^MyBIAuditLog))=auditentry
 quit

query
 set auditentry="At "_$ZDT($H,3)_", " _$USERNAME_" ran query: "_%dsQueryText
 set ^MyBIAuditLog($INCREMENT(^MyBIAuditLog))=auditentry
 quit
To use this routine, we would enter the following two lines in the Terminal:
SAMPLES>set ^DeepSee.AuditQueryCode="do query^DeepSeeAudit"
 
SAMPLES>set ^DeepSee.AuditCode="do dashboard^DeepSeeAudit"
To see the audit log, we can use ZWRITE. The following shows example results (with line breaks added for readability):
SAMPLES>zw ^MyBIAuditLog
^MyBIAuditLog=2
^MyBIAuditLog(1)="At 2014-06-20 16:26:38, SamSmith accessed dashboard: User Defined Listing.dashboard"
^MyBIAuditLog(2)="At 2014-06-20 16:26:38, SamSmith ran query: SELECT NON EMPTY {[MEASURES].[AMOUNT SOLD],
[MEASURES].[UNITS SOLD]} ON 0,NON EMPTY [DATEOFSALE].[ACTUAL].[YEARSOLD].MEMBERS ON 1 FROM [HOLEFOODS]"

Defining Server Initialization Code

To define server initialization code:
  • Place a valid ObjectScript statement in the ^DeepSee.InitCode global.
    For example, do the following in the Terminal:
    set ^DeepSee.InitCode="do ^myroutine"
    
  • Make sure that the code does not write any output to the current device.
  • Also make sure that it does not kill any % variables required by InterSystems IRIS.
This code is called by the %RunServerInitCode() method of %DeepSee.Utils. This method is called whenever an InterSystems IRIS Business Intelligence session is created.
Previous section   Next section