- The following examples are specifically for IBM Cognos 10 Report Studio based reports. It is assumed that the reader is familiar with Cognos Report Studio.
- Code development environment: IBM Cognos analtyics 11.1.x
- Dynamically add/edit text on a web page.
- Be used to create cookies which can be used to identify users.
2 – Web Page Basics
Regardless whether a web page is dynamically generated or is static, normally it contains:
- HTML tags.
- Elements or Objects, such as text, image, buttons, links etc.
- Each element has its attributes to describe how it should be displayed, such as color, size, title, ID.
- A layout so that it looks neat and readable.
- Style and formatting. Beginning with HTML 4.0, all formatting can be removed from the HTML document, and stored in a style sheet. You can still define local style on individual web pages if desired.
- Forms: to take inputs (requests) from users.
- Frames: to display multiple web pages in the same browser window.
- iFrames: to display a web page within a web page.
3 – IBM Cognos Report Page Structures
Prompt Page Structure
Typically a report prompt page will have one or more prompts and action buttons such as Cancel, Back or Finish. For demonstration purposes, let’s build a simple report with one prompt.
- Open Cognos Reporting Tool
- Select Go Sales(query) package
- Create a query named “Product Prompt Query”, drag the Product line and Product line code data items from the Products query subject under the Sales (query) namespace.
- Create a simple value prompt named “P1” which will use the Product Prompt Query. Set the “use value” to Product line code, and the “display value” to Product line.
- Type in “My Product List” in title area. The prompt page should resemble the following image:
- Save the Report
- Run the report in HTML format. You will notice the following HTML elements on prompt page:
- Report Title – “My Product List”. It’s a text element of a web page.
- Drop down list – “Product line”.
- Action Buttons – “Cancel”, “Back” (disabled), “Next”(disabled), Finish. Back and Next buttons are disabled because only one prompt page is present.
Notice that each element is nicely styled and formatted. The buttons have background images, the report title is big and bold and even the drop down box is formatted.
Report Page Structure
- Continuing on above report, go to Report Pages -> Page 1.
- Expand the Sales (query) namespace, drag Product line from Products, and Quantity and Revenue data items from the Sales query subject into the list.
- Add an optional detail filter:
.. in ?P1?
- Your report page should look like this:
- Type in “My Product List” in title area. Save the report as “mylist”.
- Run the report. When prompted don’t select any product line, you will see all product lines shown on the report:
On this report page we have:
- An IBM Cognos page header with a blue image as background.
- A report title – “My Product List” as a text element.
- A list table which holds all data retrieved. The table has header rows and is formatted by a default style sheet.
- At the bottom of page, there is also a footer which has the date, time, and page numbers. All displayed as text elements.
- With the sample “mylist” report opened in Report Studio, go to the prompt page.
- From the Insertable Objects tab, drag a HTML Item from the toolbox and place it after the report title. Double click on the HTML Item and type in the following:
<script > alert(“Hello World”);</script>
- Click on Ok, then save the report.
- Run the report and you will see a small popup window which displays the message “Hello World”
- Open a text editor, such as Notepad.
- Type in the following:
- Save it as “test.js” under the “Cognos root/webcontent” folder on your application server.
- Open the “mylist” report in Report Studio and proceed to Page 1.
- Drag a HTML Item from the Insertable Objects tab, and place it after report title. Double click on the HTML Item and type in the following:
- Save the report.
Depending on the type of the prompt object you are using. For instance, if it is dropdown box, the syntax is following:
dropdown.options[i].value – use value
dropdown.options[i].text – display value
I am trying to incorporate a pop up warning on the prompt page, the scripting does not seem to help me. Is there an XML I could try out ? Please let me know.