Professional Documents
Culture Documents
Java Script Prompts
Java Script Prompts
1
2
3
4
5
6
7
Disclaimer....................................................................................................................2
Introduction..................................................................................................................3
JavaScript Usage for Cognos Prompts........................................................................3
Retrieving prompts......................................................................................................4
4.1
Standard prompts.....................................................................................4
4.2
Other prompts..........................................................................................4
Common Actions on Prompts......................................................................................5
5.1
Modifying the prompts before the prompt page is displayed..................5
5.1.1 Set a value for a text box.....................................................................5
5.1.2 Select an item in a multiselect List Box..............................................5
5.1.3 Remove the first 2 lines from a Drop Down List prompt....................5
5.1.4 Enable the Finish button...................................................................6
5.2
Running scripts after the user clicks the Finish button............................7
Debugging JavaScript..................................................................................................8
6.1
Detecting JavaScript errors in Internet Explorer (IE)..............................8
6.2
Using Firebug debugger in Firefox..........................................................8
References....................................................................................................................8
7.1
Upgrading JavaScript Applications to IBM Cognos 8.3/8.4...................8
1 Disclaimer
The techniques in this document depend on undocumented and
unsupported aspects of the Cognos 8 Business Intelligence Cognos 8 Viewer
(AKA Report Viewer). These techniques operate in Cognos 8 Viewer only
and as such do not operate in any other Cognos 8 BI user interfaces such as
Go! Mobile, Go! Dashboards, Query Studio, Analysis Studio, Cognos
Analysis for Excel, Go!Office and so on.
While IBM will strive to provide compatibility from release to release
of Cognos 8 Viewer, all support and compatibility issues are the
responsibility of the user and not IBM.
Therefore, the use of the techniques comes with the risk of partial or
complete incompatibility with the possibility of necessitating a partial or
complete change or loss of functionality from release to release. Such risk is
borne entirely by the user of these techniques.
See also the disclaimer of the document referred in 7.1.
2 Introduction
This document attempts to consolidate and simplify some basic techniques of
using JavaScript for Cognos Prompts.
JavaScript is used to extend the prompt functionality.
The Cognos API for JavaScript prompts has been upgraded from Cognos 8.2 to
Cognos 8.3. A reference can be found in section 7.1.
The JavaScript code in this document presents by default the Cognos 8.3 version.
Notes have been added where the code is different in Cognos 8.2.
Modify the prompts before presenting the prompt page to the user
Validate user actions
Process the prompts after the user presses Finish
The JavaScript must be placed in one or more HTML items in the prompt page.
The HTML item must be placed after the prompts it refers to.
The JavaScript should be surrounded by <script> and </script> tags.
The HTML item may also contain definitions of buttons or other HTML areas.
4 Retrieving prompts
To retrieve a prompt, first get the object containing the whole form.
var form = getFormWarpRequest();
_textEditBox<prompt name>
_oLstChoices<prompt name>
_oLstChoices<prompt name>
_oLstChoices<prompt name>
_oLstChoices<prompt name>
txtDate<prompt name>
Example: to get the listBox prompt which has been named XYX, the code is:
var form = getFormWarpRequest();
var listB = form._oLstChoicesXYZ;
5.1.1
text box
5.1.2
multiselect List Box
Select an item in a
Create a Value Prompt, and change the Multi-Select property to Yes. This
example selects the third value in the list.
var form = getFormWarpRequest();
var listB = form._oLstChoicesXYZ;
listB.options[2].selected=true;
canSubmitPrompt();
5.1.3
lines from a Drop Down List prompt
5.1.4
Finish button
Enable the
In a page containing some required prompts, the Finish button is enabled only
when the user has selected values for all the required prompts.
The current section shows examples when the prompts are initialized by script. If
all the required prompts are satisfied, then the Finish button may be set to enabled, by
calling the function:
canSubmitPrompt()
canSubmitPrompt().
checkBoxGroup
clockDisplay
intervalControl
listBox
pickerControl
radioGroup
search
selectDate
selectDateTime
selectInterval
selectTime
textBox
timePicker
5.2 Running scripts after the user clicks the Finish button
By default, pressing the Finish button will execute the report with the given
prompts. In order to execute additional operations after the user presses the Finish button,
but before the report runs, replace the Finish button with a customized one, as follows:
Define a JavaScript function to do the expected actions
Define a new button to launch the function above
Remove the original Finish button
Example: a prompt page contains a list and a text box. When Finish is pressed, the
text box is filled with the selected option. The prompt page should have:
the list prompt
the text prompt
a HTML item next to the Finish button, containing:
<input type="BUTTON" class="clsPromptButton"
onClick="fillTextBox()" value="Finish">
}
}
promptButtonFinish();
}
</script>
6 Debugging JavaScript
6.1 Detecting JavaScript errors in Internet Explorer (IE)
In the bottom left corner of the IE window, usually there is the IE blue icon and
the text Done. Sometimes the icon is the yellow alert sign and the text says Error on
page. That means an error has been detected in JavaScript. By double clicking the icon,
an error dialog appears, with the line and text of the error.
7 References
7.1 Upgrading JavaScript Applications to IBM Cognos 8.3/8.4
http://www-01.ibm.com/support/docview.wss?rs=0&uid=swg24021973