Cognos Analytics

 View Only

JavaScript Samples (Custom Controls) for Cognos Analytics

By Samples Team posted Mon September 10, 2018 11:20 AM

  

[Updated: June 7, 2023]
​​

For Cognos Analytics 12.0.0, we removed all the old JavaScript samples that used .js files placed on the Cognos server and replaced them with newer versions that use uploaded Extensions to supply the JavaScript files instead. This is our new Best Practice.

Modified Team content > Samples > By feature > Custom controls

Deleted Team content > Samples > By feature > Custom controls > Extensions


As part of the Base Samples, there is a set of samples that demonstrate how to add JavaScript to your reports.

Starting in Cognos Analytics 11.2.0, all the existing JavaScript samples were modified to use uploaded Extensions to supply the JavaScript files. This is our new Best Practice. You will find these samples within Cognos Analytics here: Team content > Samples > By feature > Custom controls > Extensions


Here is a link to the technical documentation (JavaScript Modules API).

Support: For support on these objects, please contact accelerator@ca.ibm.com.

IBM will provide support if the asset does not work as described for the product version(s) identified. However, we are unable to provide custom support for you such as adding features or troubleshooting environmental issues. These will be logged in our system as future Feature requests.

These assets are functional examples. Many are code samples with narrow requirements and a specific use case, providing a baseline. They do not include every possible feature/interactivity or environment/configuration. You can use these samples as-is (supported by IBM), or you can modify/extend these samples to suit your business needs (not supported).

List of Cognos Analytics 11.2 JavaScript Samples

  • App bar: This sample report uses JavaScript to create an application bar to switch between a list, charts, and a crosstab.
  • App bar data: This sample report uses JavaScript to create a data-driven application bar.
  • App bar static labels: This sample report uses JavaScript to create an application bar with static labels.
  • Auto refresh: This sample report uses a Custom Control and JavaScript to automatically refresh the report based on a specified time interval (e.g. 15 seconds).
  • NEW for 11.2.0 Automatically pass first prompt value to report: This sample report uses a Custom Control on a Prompt Page and JavaScript in an extension to create a hidden prompt and pass the first value of Product Line Code automatically to the report.
  • Basic button control: This sample report uses a Custom Control and JavaScript to create customizable HTML buttons that filter a report.
  • Basic control: This sample shows how to include a basic JavaScript control.
  • Bootstrap button bar: This sample report uses JavaScript to create a bootstrap button bar to switch between order methods.
  • Cascading prompts with multi-select: This sample report uses a Custom Control and JavaScript to create client-side rendered cascading prompts with multi-select controls. 
  • Cascading prompts with single-select: This sample report uses a Custom Control and JavaScript to create client-side rendered cascading prompts with single-select controls. 
  • Clear prompt selections: This sample report uses JavaScript modules to clear selections from all prompts.
  • Collapse regions: This sample report uses JavaScript to show or hide prompts.
  • Collapse regions and subsections: This sample report uses JavaScript to show or hide prompts, and to show or hide individual prompts within that region.
  • NEW for 11.2.0 Customize prompt text: This sample report uses a Page Module and JavaScript in an extension to style the text in a prompt control
  • D3 bar chart: This sample report uses JavaScript to generate a D3 bar chart.
  • Data store viewer: This sample report uses JavaScript to access the data store and display rows of data.
  • Date prompt presets: This sample report uses JavaScript modules to provide the user with a set of prompt selection presets based on today's date.
  • Display all prompt values ignoring user selections: This sample report uses JavaScript modules to display all the values in the prompt, whether they are selected or not.
  • Display user selected prompt values: This sample report uses JavaScript modules to display the prompt values selected by the user.
  • Events: This sample report demonstrates how to use JavaScript to respond to events.
  • Google bar chart: This sample report uses JavaScript to generate a Google bar chart.
  • HTML select: This sample report uses JavaScript to create an HTML drop-down list.
  • HTML slider: This sample report uses JavaScript to create an HTML slider to set a minimum value.
  • HTML submit and cancel buttons: This sample report uses a Custom Control and JavaScript to create custom HTML buttons for Submit (renamed from Finish) and Cancel. CSS in the JavaScript creates the button hover color.
  • Indexed prompt: This sample report uses a Custom Control and JavaScript to create a client-side indexed prompt. It creates an alphabetical index based on the first letter of only the Product Types that are available in the data.
  • Info icon: This sample report uses a Custom Control and JavaScript to create an Information icon that users can hover over to display text or an image.
  • Limit numeric prompt selection by database value: This sample report uses a JavaScript page module to restrict a value prompt to the range of values in the database for the Product Number field.
  • Limit time between two dates: This sample report demonstrates preventing the user from selecting a date range greater than 10 days.
  • Limit user selection to two items: This sample report shows how to validate prompt values to stop the user from selecting more than 2 items.
  • List column display: This sample report uses JavaScript to allow the user to select which list columns to display.
  • Loading text: This sample demonstrates loading text with JavaScript.
  • Page module: This sample report demonstrates how to author a page module and access a control in the page module. (This is the base template for a page module.)
  • Personal default prompt selections – set selections: This sample report allows the user to save a set of default prompt selections for use in subsequent reports. The prompt selections are saved to browser cookies.
  • Personal default prompt selections – use selections: This sample report shows how to use the personal default prompt selections.
  • Prompt API buttons: This sample report uses JavaScript to show the results of various method calls.
  • Prompt validation: This sample demonstrates using JavaScript to validate the content of prompt values entered by the user.
  • Validate prompt values when button pushed: This sample report demonstrates how to validate prompt values when a prompt button is clicked.
  • Validate type-in postal code values: This sample report uses a JavaScript page module to validate user input character by character as the user types to ensure that a valid postal code is entered.
  • Validate type-in product line code: This sample report uses a JavaScript page module to validate user input character by character as the user types to ensure that a valid product line code is entered.

Please note: These samples may be improved with each new release of IBM Cognos Analytics and as a result they may not be backward compatible.




Starting in Cognos Analytics 11.1.5, the JavaScript samples are part of the Base Samples. You will find them here: Team content > Samples > By feature > Custom controls

You no longer need to install and configure the JavaScript samples yourself!



In Cognos Analytics 11.1.4 and below, the setup instructions and JavaScript sample files are installed (but not configured or imported) with the product during installation. You can find the files here: [Cognos Analytics installation directory]\samples\JavaScript\

Very Important: Please open the file JavaScript_setup_instructions.pdf and follow the steps. If you don't follow the steps, the samples won't work. After completing the steps, you will find the JavaScript samples under Team content > Samples > JavaScript. There is a report named !Table of contents that provides descriptions and links to each sample.

Tip: The tricky part for most customers is the fact that the JavaScript module paths must be configured to match your environment (dispatcher or gateway). This process is described in detail in the file JavaScript_setup_instructions.pdf.



Beginning in Cognos Analytics 11.0.10, all the JavaScript samples now use a data module as their data source, making them much easier to import. You no longer need to install the full Extended Samples in order to use the JavaScript samples.

 


JavaScript in Cognos Business Intelligence 10

Cognos Business Intelligence 10.2.2 uses HTML Items, JavaScript, and the Prompt API. The report is rendered in the Classic Viewer only. IBM Cognos Analytics 11.0.4+ uses Custom Controls (instead of HTML items) and JavaScript modules. The report is rendered in the Interactive Viewer.



Related posts:




Types of Samples:
Base Samples | Extended Samples | JavaScript | Themes and Extensions | Audit Reporting | OLAP | Package Based Drill-Through | Legacy | 10.2.2 Cognos Mashup Services (CMS) | Notebooks



Please visit our Cognos Analytics playlist on YouTube.



Tags:
#Cognos Analytics
#JavaScript
#reporting
#Scriptable report
#samples​​​​​​​

#11.0.11​



#CognosAnalyticswithWatson
#home
#LearnCognosAnalytics
#Notebook
#prompts

0 comments
630 views

Permalink