IBM Cognos 8 Advanced Reporting – Hidden Prompts
In the past, we have introduced techniques around dynamic prompting by utilizing a number of Cognos Report Studio built-in features. Occasionally there are scenarios that will necessitate the need to set a report parameter without prompting the user to select a value. For instance, there may be a case where the report developer needs to pass both the selected year and the previous year to a stored procedure or pass in a calculated prompt value that would be based on previously selected prompt values. While there are a number of solutions for such scenarios, in this article we will focus on a Javascript based technique to provide the necessary functionality.
Development Environment
IBM Cognos 8.4 using Internet Explorer 6.0 or Higher
Note: This technique uses JavaScript against underlying report objects in a Cognos BI report. For this reason, there is no guarantee that this solution will work for other versions of Cognos due to the structural differences within the applications components when compared to the tested version. .
Step by Step Instructions
- Launch report studio, select Go Sales(query) package.
- When prompted, choose create a new report with a list template.
-
From the Sales(query) namespace, drag Quantity and Revenue data items from the Sales query object. Add in the Year data item from the Time dimension. Your list report should appear as follows:
- Navigate to Page Explorer -> Prompt Pages, drag in a new prompt page.
- Drag a value prompt to the prompt page, and set the parameter as “pYear” when prompted to create a new parameter in the prompt wizard .
-
Enter “Year” as the name of prompt object (Under properties/Miscellaneous)and click on Finish.
- Add in a text item to describe the prompt.
-
Under the prompt properties, add in static choices values: 2005, 2006, 2007.
- Set the data format property to number with zero decimal places.
-
Drag a text box prompt onto the prompt page. Set the parameter name to “pYearLess” in the wizard and set its object name to “YearLess”.
-
Your prompt page should now resemble the following:
- Delete the default Finish button.
- Add a HTML item after the Next prompt button.
-
Type in the following JavaScript code in the HTML item:
<button class=”bp” onClick=”setYearPrompts();”>Finish</button>
<script type=”text/javascript”><!–
function setYearPrompts()
{
var fW = (typeof getFormWarpRequest == “function” ?getFormWarpRequest() : document.forms[“formWarpRequest”]);
fW._textEditBoxYearLess.value=fW._oLstChoicesYear.value -1;
promptAction(“finish”);
}
//–></script>
-
Navigate to the report page and add in the following filter to the report:
- Run report and you will notice that the report is actually filtered by the hidden prompt value (User selected year minus one).
JavaScript is a very powerful technique available to report authors in IBM Cognos Report Studio. However, in many cases the code is tied to the underlying Cognos web page structure, which in return brings in some overhead on maintenance and upgrade oriented activities. For this reason, it is imperative that Javascript is used judiciously during report development.