top of page

CEL: common JS API util.js

ABSTRACT (by Federico Levis ) Category: CEL

Common JS API that can be used in CEL or also in generic JS

Prerequisite:

2 Options

a) Cognos Extension Library (CEL) is installed and included in your Report

b) Only CommonJSApi are included in your Report

util.js contains many JS API for Cognos RS. Most of these APIs could be useful also in whatever JS files, also outside of Cognos environment. We will describe some of these JS APIs

1. APIs to get Cognos Prompt Object

For example we suppose to have a Cognos Date Prompt with name = _filterFromDate

To retrieve the relative Cognos Propmpt Object we have to simply call the util.js API:

var bShowEr = true;

var pmtDataDa = APIgetPromptByName ("_filterDateFrom",bShowEr);

If we have wrongly designed the Report (e.g. the Name we pass to the API is wrong), the API will show an Error if bShowEr=true. For example:

2. Cognos prompt validate APIs

util.js have many validate function. For example with a single call to function prompDateFromToValidate we will validate the Format of From and To Date and also their relation. For example

Date Format validation

From/To Date Relation validation

3. Internationation Language Support for Messages: English (default) and Italian

All the Message Box (alert) displayed are in English (default). Howvere Language can be changed with utilSetLanMsg

/*-------------------------------------------------------------------------

Change Language for User Error Msg (e.g validation). Default is LAN_MSG_ENG

@param szLanMsg in LAN_MSG_ITA for Italian, LAN_MSG_ENG for English (Default)

-----------------------------------------------------*/

function utilSetLanMsg (szLanMsg){....}

for example after calling utilSetLanMsg (LAN_MSG_ITA) previous Date Prompt Validation message will become:

4. Instant Modification APIs for Cognos Cascading Prompt

The traditional Cognos Cascading prompt approach requires Page Refresh and Query re-execution, that usually means some seconds to wait.

utils API provide you the possibility to easy implement "Instant Modification" with some useful APIs like:

function arPmt2Select (..)

function arPmtFromSelect (..)

With this JS API approach (detailed described in CEL examples) you can change instantly the contents of Prompt2 basing on Prompt1 selection.

Comentarios


bottom of page