- IBM Cognos 8 Report Studio Cookbook
- Abhishek Sanghani
- 581字
- 2021-08-06 17:15:51
Automatic selection and submission of values
A business report has numerous prompts on the prompt page. Often, users want to run a report for the latest month in the database, 'Camping Equipment' product and 'E-mail' as a order method.
They want a facility to either manually select vales for these prompts; or alternatively, run the report for the above selections on single button click.
In this recipe, we will add a custom button on prompt page that will allow users to quickly run the report for frequently used selections.
Getting ready
Create a list report with product line, order method, and sales quantity as columns.
Create optional filters on product line, order method, and Shipment Month that is, Month Key (Shipment Date).
Create a prompt page with three value prompts for these filters.
How to do it...
- We will start by wrapping the prompts within spans, so that they can be captured easily in JavaScript. Add one HTML tag before and one after each prompt to define Spans. Define the spans as PL, OM, and SM for Product Line, Order Method, and Shipment Month respectively. This is similar to the wrapping we did in most of the prior recipes.
- Add one more HTML item on the prompt page after all the prompts, and define it as follows:
<script> function defaultSelect() { var a = document.getElementById("PL"); var PL = a.getElementsByTagName("select"); for( var i = PL.length-1; i >= 0; i-- ) /* Captures Product Line prompt */ { var PLBox = PL[i]; } a = document.getElementById("OM"); var OM = a.getElementsByTagName("select"); for( var i = OM.length-1; i >= 0; i-- ) /* Captures Order Method prompt */ { var OMBox = OM[i]; } a = document.getElementById("SM"); var SM = a.getElementsByTagName("select"); for( var i = SM.length-1; i >= 0; i-- ) /* Captures Shipment Month prompt */ { var SMBox = SM[i]; } PLBox.selectedIndex = 2; OMBox.selectedIndex = 2; SMBox.selectedIndex = 2; canSubmitPrompt(); promptButtonFinish(); } </script> <button type="button" onclick="defaultSelect()" class="bt" style="font-size:8pt">Run for Defaults</button>
Now your prompt will look similar to the following screenshot in Report Studio:
- Run the report to test it. You should see a button that you did not see in Report Studio. When you click on the button, it will automatically select the prompt values and run the report.
How it works...
In this recipe, we are mixing two techniques learnt from previous recipes. In the Dynamic default selection recipe, we learnt how to capture a value prompt and change its selection.
So, we are using the same technique here but instead of calling on Page Load, we are calling the routine when users click on the button.
Then we are also using a function promptButtonFinish()
that we used in the 'Textbox validation' recipe to submit the prompt.
The custom button is defined using <button>
tag and as it is our own object, we can easily make it call our JavaScript function for the onclick event.
As mentioned in the 'Dynamic default selection' recipe, practically you will not hard-code the selectedIndex
in your script. Instead, you should traverse through all prompt selection options and choose one based on the value. For example, look for 'Camping Equipment' so that its order in the list won't matter.
Please refer to one such example on the IBM website at this URL: http://www-01.ibm.com/support/docview.wss?uid=swg21343424
There's more...
This technique is very useful in real-life scenarios. You can define multiple buttons for different frequently used selections. It saves time for users and makes the reports convenient to use, especially when there are more than five prompts.
- WordPress 2.7 Cookbook
- Microsoft BizTalk Server 2010 Patterns
- 圖解Word 2007圖文排版與辦公應(yīng)用
- Adobe創(chuàng)意大學InDesign CS5 版式設(shè)計師標準實訓教材
- AI短視頻生成與剪輯實戰(zhàn)108招:ChatGPT+剪映
- Adobe創(chuàng)意大學Photoshop產(chǎn)品專家認證標準教材(CS6修訂版)
- ASP.NET 3.5 Social Networking
- 中文版Photoshop CS6完全自學手冊(超值版)
- Unity 3D游戲開發(fā)(第2版)
- Apache CXF Web Service Development
- Photoshop CC中文版基礎(chǔ)教程
- Photoshop-CorelDRAW 基礎(chǔ)培訓教程
- Maya Paint Effect 特效應(yīng)用手冊
- Magento 1.4 Development Cookbook
- SolidWorks 2020中文版入門、精通與實戰(zhàn)