Cognos TM1 Web JavaScript library Workbook class

The Workbook class represents a Cognos® TM1® Web Websheet object.

Workbook objects extend the Dojo widget object (dijit._WidgetBase) and can be assigned as a child object of a Dojo tab container (dijit.layout.TabContainer) or other container. For more information, see Dojo documentation (http://dojotoolkit.org/documentation/).

In addition to the available properties and methods of the Dojo widget object, Workbook objects also have TM1 related properties and methods that you can access programmatically.

Workbook objects are loaded asynchronously and must finish loading before your code can interact with the objects.

Format

You load a Websheet object by using the following format to specify the required properties and optional functions that define the object.

new Workbook({properties ..., functions ...});

Properties

The properties include the following values that define the Websheet object.

  • adminHost
  • tm1Server
  • username
  • password
  • camPassport
  • sessionToken
  • path
Note: You can provide login credentials as either a session token or by including separate values for TM1 Admin host, TM1 Server, user name, password, or camPassport.
Functions

The functions can include the following optional code:

  • Use the onLoad function so that you can be notified when the object is loaded and ready to interact with.
  • Use the onTitleDimensionElementChange declaration so you can process the event when a user changes a dimension title in the related object.

Example

The following example shows a JavaScript function that uses a combination of JavaScript and Dojo syntax to load a Websheet object.

The login credentials are provided by using a session token.

// Load Websheet with a session token
function loadWebsheet() {
    require([
        "tm1web/websheet/Workbook",
        "dojo/_base/unload",
    ], function(Workbook, unload){
        loadedWebsheet = new Workbook({
            sessionToken: "yourSessionToken",
            path: "Applications/Planning Sample/Management Reporting/Actual v Budget",
            title: "Active v Budget",
            onLoad: function() {
                console.debug("Workbook loaded successfully.");
            },
        });

        // Assign object to a UI container
        dijit.byId("tabContainer").addChild(loadedWebsheet);

        loadedWebsheet.startup();

        unload.addOnUnload(function() {
            loadedWebsheet.destroy();
        });
    });
};