Adding JavaScript to a report
Add JavaScript to a report to provide your own user interfaces when the report is run in HTML.
About this task
In IBM® Cognos® Analytics, you can add JavaScript in the following ways.
- As with IBM Cognos Business Intelligence releases, you can add JavaScript in HTML item objects.
In Cognos Analytics, JavaScript in HTML items is executed only when the report is run with limited interactivity (the report property Run with full interactivity is set to No).
Note: If you run a report with full interactivity, use HTML items to insert only static HTML or static CSS into the report output. - You can add JavaScript to reports by using two types of Asynchronous Module Definition (AMD) modules.
With this choice, JavaScript is executed when the report is run with full interactivity (the report property Run with full interactivity is set to Yes).
The JavaScript must exist in a separate file that your browser can access.
The two types of AMD modules that you can use are
- A module that implements the
CustomControl Module
interface. - A module that implements the
Page Module
interface.
You add a CustomControl Module
interface to a report by referencing the interface in a custom control object. The reference is a file location that you specify in the Module path property of the custom control. Add a custom control to provide your own user interface for a prompt-like control that reads and sets parameters or for page navigation buttons.
You add a Page Module
interface by referencing the interface in a report page or a prompt page. The reference is a file location that you specify in the Module path property of the page. Add a page module to set the initial state of prompt controls, to set prompt control custom validation functions, or to read current selections from a prompt control.
For information about the JavaScript that Cognos Analytics supports, see the technote Adding JavaScript to a report (www.ibm.com/support/docview.wss?uid=swg21990557) and article describing the list of JavaScript samples (https://community.ibm.com/community/user/businessanalytics/blogs/steven-macko/2018/03/22/updated-javascript-samples-for-ibm-cognos-analytics-11010?CommunityKey=6b10df83-0b3c-4f92-8b1f-1fd80d0e7e58&tab=recentcommunityblogsdashboard).