You are on page 1of 11

More

Next Blog

Create Blog

Cognos on Steroids
About the Author Monday, January 30, 2012

About the Author Sriram is a Sr. Business Intelligence Developer with more than 7 years of experience in designing reporting solutions for data warehouses. You can contact the author by email at cognosonsteroids@hotmail.com
Add this widget to your blog

Hide Toolbar Buttons in Cognos Viewer


Recommend this on Google

Business Case: Report Author wants to hide the individual toolbar buttons found in Cognos Viewer or the entire toolbar. Environment: IBM Cognos 8, Report Studio, Javascript, HTML Format, Internet Explorer/Mozilla Firefox. Examples: There are many reasons why a report author might want to hide the buttons or the toolbar. For example, if a report is a drill through target report, then the users shouldn't be able to run the report again from within the cognos viewer as parameters will not be passed. Another example is, if the drill through report can be viewed only in one format, then the author might want to hide the Report Formats button. Implementation: The toolbar inside the Cognos Viewer and it's buttons are nothing but HTML elements. So, we can use Javascript to hide them. There are two different scripts that can be used to achieve this. Script 1 - Use IBM's built in Object Names and Methods to hide individual elements: IBM provides this script in their knowledge base. I am using a shorter and slightly modified version of this script here: < s c r i p tl a n g u a g e = " J a v a S c r i p t " > / /L i c e n s e dM a t e r i a l-P r o p e r t yo fI B M / /C o p y r i g h tI B MC o r p o r a t i o n2 0 0 3 ,2 0 0 9 f u n c t i o nh i d e K e e p V e r s i o n ( ) { d o c u m e n t . g e t E l e m e n t B y I d ( " _ N S _ k e e p T h i s V e r s i o n " ) . s t y l e . d i s p l a y=" n o n e " ; } v a rt b C u r r e n t=n u l l ; v a rh i d e T h e K e e p V e r s i o n B u t t o n=t r u e ; v a ry = g e t F o r m W a r p R e q u e s t ( ) . e l e m e n t s [ " c v . i d " ] ; / /R Sm e a n si th a sb e e nl a u n c h e df r o mR e p o r tS t u d i o / /_ N S _m e a n si th a sb e e nl a u n c h e df r o mC o g n o sC o n n e c t i o n i f ( y . v a l u e= =" R S " ) t b C u r r e n t=o C V R S . r v M a i n W n d . g e t T o o l b a r ( ) ; e l s e t b C u r r e n t=o C V _ N S _ . r v M a i n W n d . g e t T o o l b a r ( ) ; i f ( y . v a l u e= =" _ N S _ "& &h i d e T h e K e e p V e r s i o n B u t t o n ) s e t T i m e o u t ( " h i d e K e e p V e r s i o n ( ) " , " 5 0 " ) ; v a rt b I t e m s=t b C u r r e n t . m _ i t e m s ; f o r( v a ri t e mi nt b I t e m s ) { / /H i d eD r i l lU pa n dD r i l lD o w nB u t t o n s i f( t b I t e m s [ i t e m ] . m _ i d= =y . v a l u e+' d r i l l U p '| |t b I t e m s [ i t e m ] . m _ i d= = y . v a l u e+' d r i l l D o w n ' ) { t b I t e m s [ i t e m ] . h i d e ( ) ; } / /H i d eO p e nW i t hB u t t o n i f( t b I t e m s [ i t e m ] . m _ i d= =y . v a l u e+' o p e n W i t h ' ) { t b I t e m s [ i t e m ] . h i d e ( ) ; } / /H i d eR u nR e p o r tB u t t o n i f( t b I t e m s [ i t e m ] . m _ i d= =y . v a l u e+' r u n R e p o r t ' ) { t b I t e m s [ i t e m ] . h i d e ( ) ; } } < / s c r i p t >

Support Cognos On Steroids

You can help keep this site alive.

Total Pageview s

103,112
Blog Archive

2013 (1) 2012 (17) September (1) June (1) April (1) March (3) February (2) January (9) Hide Toolbar Buttons in Cognos Viewer Explaining Report Specification Update Report Specification Without SDK Show or Hide List Report Columns using Javascript Clear Value Prompt Selections Using Javascript Crosstab with Non-Numeric Fact Use the Same Report for Scheduling and Manual Run Show or Hide any Element in the Report using Javas... Validate Value Prompt using Javascript 2011 (5)

Follow ers

Join this site


w ith Google Friend Connect

Members (26)
More

Already a member? Sign in

2GB+ Free Online Storage Access your files from anywhere & from any device (PC, Mac, iPhone or Android)

The advantage of this script is that it provides a handle for each of the toolbar buttons individually. On the flip side, since these are built in objects, it doesn't give much room for tweaking or manipulating and it's more of a use as is approach. Link to IBM Knowledge base Article. Script 2 - Use HTML DOM objects to hide the toolbar: This is a much simpler script. The script scans the HTML page and looks for the toolbar. It then hides the toolbar completely. < s c r i p tt y p e = " t e x t / j a v a s c r i p t " > v a rt a b l e s=d o c u m e n t . g e t E l e m e n t s B y T a g N a m e ( " t a b l e " ) ; v a rt d s=d o c u m e n t . g e t E l e m e n t s B y T a g N a m e ( " t d " ) ; f o r( v a ri = 0 ; i < t d s . l e n g t h ; i + + ) { i f ( t d s [ i ] . i d . i n d e x O f ( " C V T o o l b a r " )= =0 ) { a l e r t ( " F o u n dT o o l B a r :"+t d s [ i ] . i d+"-"+ t d s [ i ] . i d . i n d e x O f ( " C V T o o l b a r " ) ) ; t d s [ i ] . s t y l e . d i s p l a y=' n o n e ' ; } } < / s c r i p t > How to use the scripts: Create an HTML element at the end of the page and place the script in there. The script will work in both Firefox and Internet Explorer.
Posted by Sriram at 5:14 PM 10 comments Links to this post

www.dropbox.com

Sunday, January 29, 2012

Explaining Report Specification


Recommend this on Google

Report Specification: From Cognos point of view, when we say "Report", we are referring to a "Report Specification". When you create a report in Cognos, you are not storing the report output or data or even the query. Let me be clear; you can save the report output in cognos, but this is not what you typically do when you create a report. When you create and save a report what you are saving in your "Public Folder" or "My Folder" is an XML specification that contains details about the report. The details include things like: the package your report is associated with the location where the report is stored the location of the package list of queries, query items, filter expressions etc. These details are stored in plain text as an XML file. For example, a blank report you save in the cognos portal will have the following specification:

< r e p o r tx m l n s = " h t t p : / / d e v e l o p e r . c o g n o s . c o m / s c h e m a s / r e p o r t / 6 . 0 / " e x p r e s s i o n L o c a l e = " e n u s " > < m o d e l P a t h > / c o n t e n t / f o l d e r [ @ n a m e = ' P a c k a g e s ' ] / p a c k a g e [ @ n a m e = ' E n t e r p r i s eD a t a W a r e h o u s e ' ] / m o d e l [ @ n a m e = ' m o d e l ' ] < / m o d e l P a t h > < d r i l l B e h a v i o rm o d e l B a s e d D r i l l T h r u = " t r u e " / > < l a y o u t s > < l a y o u t > < r e p o r t P a g e s > < p a g en a m e = " P a g e 1 " > < s t y l e > < d e f a u l t S t y l e s > < d e f a u l t S t y l er e f S t y l e = " p g " / > < / d e f a u l t S t y l e s > < / s t y l e > < p a g e B o d y > < s t y l e > < d e f a u l t S t y l e s > < d e f a u l t S t y l er e f S t y l e = " p b " / > < / d e f a u l t S t y l e s > < / s t y l e > < c o n t e n t s / > < / p a g e B o d y > < / p a g e > < / r e p o r t P a g e s > < / l a y o u t > < / l a y o u t s > < X M L A t t r i b u t e s > < X M L A t t r i b u t en a m e = " R S _ C r e a t e E x t e n d e d D a t a I t e m s "v a l u e = " t r u e " o u t p u t = " n o " / > < X M L A t t r i b u t en a m e = " l i s t S e p a r a t o r "v a l u e = " , "o u t p u t = " n o " / > < / X M L A t t r i b u t e s > < / r e p o r t >

You can see some of the details that I mentioned about above. The report specification can be viewed in Report Studio by clicking the "XML" icon on the toolbar or by selecting "Copy Report to Clipboard" option from the Tools menu. Any change you make inside report studio like adding a query item, changing the font to bold or adding a new table in the report page will be reflected in the report XML. When you save the report, Cognos saves this specification in the content store. Report Execution: When a report is "Run" or executed, cognos generates the SQL from each of the queries in the report, passes the queries to the source database and formats the output according to your report layout. Note that all these happen when you execute the report and not when you save the report.
Posted by Sriram at 7:27 PM 2 comments Links to this post

Tuesday, January 24, 2012

Update Report Specification Without SDK


Recommend this on Google

Business Case: There were many times, when I wanted to do update the specification of one or more reports. In one instance, a complex report with close to 10 queries needed to be modified because it was using the incorrect revenue field. In another case, the business users decided to change the name of a data item in the Cognos package. Unfortunately there were about 20 reports that used this data item, which meant I have to edit each of these reports and repoint the query item to the correct one. In yet another case, a filter expression in a report with a large number of queries had to be modified. Report Specification: In order to keep this article short, I have moved the explanation of Report Specification to a separate post. If you would like to understand what a report specification is, read this article first: Explaining Report Specification Modifying the Report Specification: When a report needs to be modified, we usually edit the query or page in Report Studio and make the necessary changes to the layout or report expression. This is fine as long as you have to change just one expression or formatting in one place. But this is not always the easiest way. Example: Let's take the first business case I mentioned above. Suppose that you have a report with 10 queries that have [Billing Address]. On top of this the term "Billing Address" is used in multiple pages and multiple places in the report (header, column title, foot notes etc). The report user comes to you, the author, and requests you to change all references to Billing Address to Shipping Address, which already exists in the package. In this case, editing the report in report studio to find every instance of [Billing Address] and changing it to [Shipping Address] is a tedious process. It is highly inefficient too. Here is a quick way to change the report. Open the report in Report Studio From "Tools" menu, click "Copy Report to Clipboard". This will copy the report specification (read, Report XML) to the clipboard. Open a text editor like Notepad or Textpad and paste the XML code. Do a simple "Find and Replace" in your text editor. Find all instances of "Billing Address" and change to "Shipping Address" (don't use the double quotes). Note that since we are looking for the text "Billing Address", you will be changing everything that has "Billing Address" including column titles, report header, query item names etc. If you want to change only the report expressions, add square brackets when you find and replace, "[Billing Address]" to "[Shipping Address]". Now "Select All" in your text editor and "Copy" (CTRL+C). Open a new report studio window and from the Tools menu, select "Open Report from Clipboard". This will open a new report. You can now validate the report and save it (either overwrite the existing report or save it as a new report). The entire process will take you about 2 minutes. Remember.. There is more than one way to skin a cat.. Let's do it the easy way. In the next article, I will talk about how to update the report specifications of multiple reports by altering the report specifications (without the use of SDK).

Posted by Sriram at 4:24 PM

1 comments

Links to this post

Wednesday, January 18, 2012

Show or Hide List Report Columns using Javascript


Recommend this on Google

Business Case: Report author wants to create a list report in, which, any of the columns can be shown/hidden after the report execution is complete. Environment: IBM Cognos 8, Internet Explorer/Mozilla Firefox, Javascript, HTML format reports.

Example: A report is used by many users. This report has many columns, and depending on which user is viewing the report, users might want to temporarily hide one or more columns and later unhide them. Note: This requirement is different from the case where users know before executing the report, which columns need to be displayed. If the users know beforehand, Render Variable can be used to hide the columns. But in this case, the columns cannot be shown again without re-running the report. Since this solution is implemented using javascript, it goes without saying that it works only when the report is run in HTML format. I have tried this with a list report, but the script should work for crosstabs as well. If you have trouble making this work in crosstabs, please post in the comments section. Implementation: Implementing this requirement needs some placeholder HTML items on the page in addition to the main script. The list report in cognos is rendered as a table in the cognos viewer, consisting of rows and columns. Unfortunately, the entire page in Cognos viewer consists of rows and columns. In order to identify the list report, we will be unlocking the cells and placing an HTML item in the report title section in one of the list columns (it doesn't matter which column). The HTML item will have the following script: < s p a ni d = " l i s t " > < / s p a n > Now we need a bunch of links outside the list report that can be used to toggle (show/hide) the columns. You can create this just before the list report, but it won't work if your report spans multiple pages. I placed this in the page header, since the header spans across all the pages. I created a table with one row and 5 columns one for each column in my list report. I then placed, one HTML item in each column. The HTML items will have the following scripts. S c r i p ti n1 s tH T M Li t e m :< ah r e f = " j a v a s c r i p t : h i d e C o l u m n ( 1 ) " > S t r i n g < / a > S c r i p ti n2 n dH T M Li t e m :< ah r e f = " j a v a s c r i p t : h i d e C o l u m n ( 2 ) " > I D < / a > S c r i p ti n3 r dH T M Li t e m :< ah r e f = " j a v a s c r i p t : h i d e C o l u m n ( 3 ) " > N a m e < / a > S c r i p ti n4 t hH T M Li t e m :< ah r e f = " j a v a s c r i p t : h i d e C o l u m n ( 4 ) " > T y p e < / a > S c r i p ti n5 t hH T M Li t e m :< ah r e f = " j a v a s c r i p t : h i d e C o l u m n ( 5 ) " > F l a g < / a > If you notice above you have match the column number and name to your list report. Now the report layout should look like this

The last piece is the HTML item for the main script. You can place this just after the list, but to support reports that span multiple pages, I placed it in the page footer. The main script is as follows: < s c r i p t > f u n c t i o nh i d e C o l u m n ( c o l N u m ) { v a rl i s t H e a d e r=d o c u m e n t . g e t E l e m e n t B y I d ( " m a r k e t " ) ; v a rt a b l e=l i s t H e a d e r . p a r e n t N o d e . p a r e n t N o d e . p a r e n t N o d e . p a r e n t N o d e ; v a rr o w s=t a b l e . g e t E l e m e n t s B y T a g N a m e ( " t r " ) ; f o r ( v a ri = 0 ; i < r o w s . l e n g t h ; i + + ) { v a rc e l l s=r o w s [ i ] . g e t E l e m e n t s B y T a g N a m e ( " t d " ) ; i f ( c e l l s [ c o l N u m 1 ] . s t y l e . d i s p l a y= =' n o n e ' ) { c e l l s [ c o l N u m 1 ] . s t y l e . d i s p l a y=' ' ; } e l s e { c e l l s [ c o l N u m 1 ] . s t y l e . d i s p l a y=' n o n e ' ; } } } < / s c r i p t > When the report is executed, it should look like this:

You can see that, my report spans multiple pages. When I click the link "String" the first column will be hidden and the report will look like:

You can see that even though the column is hidden, the link "String" is still visible. You can click on this link again to show the "String" column. I clicked on the "Type" link and now the report looks like this:

Even though the approach may seem long, it is pretty simple. The advantage of this script is that, since we are not manipulating any cognos objects like prompts, this script should work for most versions of Cognos. The script has been tested in both Internet Explorer and Firefox. This should score you some points with your users.. Have fun...

Posted by Sriram at 11:34 AM

18 comments

Links to this post

Friday, January 13, 2012

Clear Value Prompt Selections Using Javascript


Recommend this on Google

Business Case: User wants a clickable link on the prompt page to clear all prompt selections. Environment: Cognos 8.4, Report Studio, Javascript, Mozilla Firefox / Internet Explorer

Implementation: This can be achieved using Javascript. Place an HTML item at the end of the prompt page after all the prompts. Place the code from the next section into the HTML item. You can use a table to position the link on the page. When the report is executed, user will see a link "Clear All Selections", which will reset all the prompt selections. Code: < s c r i p t > v a rl i s t _ p r o m p t s=d o c u m e n t . g e t E l e m e n t s B y T a g N a m e ( " s e l e c t " ) ; f u n c t i o nC l e a r S e l e c t i o n s ( ) { f o r( v a ri = 0 ; i < l i s t _ p r o m p t s . l e n g t h ; i + + ) { l i s t _ p r o m p t s [ i ] . s e l e c t e d I n d e x=1 ; } } < / s c r i p t > < ah r e f = " J a v a S c r i p t : C l e a r S e l e c t i o n s ( ) " > C l e a rA l lS e l e c t i o n s < / a >
Posted by Sriram at 4:03 PM 4 comments Links to this post

Wednesday, January 11, 2012

Crosstab with Non-Numeric Fact


+3 Recommend this on Google

Business Case: The user wants to display the data in a crosstab format but the values in the intersection are not numeric. Example 1: User wants a matrix of product reviews. The crosstab rows should have Orders (Order ID)and columns should have products (Product Name). The crosstab cells (intersection of product and order) should contain the text "Positive" or "Negative" depending on what review the customer gave for each product. Solution: Crosstab reports in Cognos are used to display summary values. For example, Order Quantity for each product/order combination would be easy to achieve. If you have a fact that is non numeric, the report will be blank. However, there is a work around for the kind of requirement explained in Example 1 above. Let's look at the implementation below. Report Input and Ouput: Let's look at the data structure first. In the example above, we have 3 query items: Order ID, Product Name and Feedback. The data will look like this:

The expected report output is like this:

Implementation: First, we need to create a numeric fact equivalent for the non-numeric fact. In this case, I created a data item Feedback_Numeric with this expression: C a s eW h e n[ S Q L 1 ] . [ F E E D B A C K ]=' P o s i t i v e 'T h e n1W h e n[ S Q L 1 ] . [ F E E D B A C K ]= ' N e g a t i v e 'T h e n1E l s eN u l lE n d Set the "Aggregate Function" and "Rollup Aggregate Function" properties of this query item to "Total" Now, create a crosstab report in the report page, drag [Order ID] to the rows, [Product Name] to the columns and [Feedback Numeric] to the measures. Create a new String Variable "Feedback Variable" with the following expression: C a s e[ Q u e r y 1 ] . [ F e e d b a c kN u m e r i c ] W h e n 1T h e n' P o s i t i v e ' W h e n 2T h e n' N e g a t i v e ' E l s e' N u l l ' E n d Your condition explorer should look like this:

Next, unlock the cells by clicking the lock icon on the toolbar. Select the text of the query item in the crosstab. Make sure, you are selecting only the text portion of the cell,

not the entire cell (see image below).

In the properties pane, edit the "Text Source Variable" property and set it to "Feedback Variable" Now expand the "Conditional Explorer" and select "Positive" Click the text part of "Feedback Numeric" measure in the crosstab and in the properties pane, change the "Source Type" property to "Text". Edit the text item in the crosstab cell and type "Positive" Do the same thing for "Negative" case in the Conditional Explorer. For "Null" condition, edit the text to put "No Feedback" or you can put a white space as I did. Now, if you run the report, the output should be like the second image above. Have fun..
Posted by Sriram at 6:31 PM 10 comments Links to this post

Tuesday, January 10, 2012

Use the Same Report for Scheduling and Manual Run


Recommend this on Google

Business Case: A scheduled report with a date filter should be customized to be used with date prompts. Environment: IBM Cognos 8.4.1, Report Studio Example: I had built a scheduled report for my users that had a date filter for the past 7 days. This report was scheduled to run every Monday and email the results to the users. The users wanted to be able to run this report for custom dates as well. Solution: This is a pretty standard request that I had come across many times. When the report has a date filter using 'current_date' as the time of reference, then the report can be scheduled without a date prompt. For a report that should filter for the past 7 days, the filter will look like this: [ O r d e rD a t e ]b e t w e e n_ a d d _ d a y s ( c u r r e n t _ d a t e , 7 )a n d_ a d d _ d a y s ( c u r r e n t _ d a t e , 1 ) When the same report has to take date as input, users generally tend to take the easiest approach of making a copy of the report and change the filter to use parameters that get values from date prompts. The new filter will look like this: [ O r d e rD a t e ]b e t w e e nc a s t ( ? s t a r t _ d a t e ? , d a t e )a n dc a s t ( ? s t a r t _ d a t e ? , d a t e )

There is nothing wrong with this approach, except that, now you have two reports that have the same business logic and layout, but have to be maintained separately. If there's a change in the logic or layout, it has to be done in two places. This becomes cumbersome when the report is complex and has many queries. As a best practice, I always like to merge the two requirements into a single report by adding a value prompt to the report. Let's see how this is done. This solution can be adopted for any scenario that requires a separate filter for manual vs. scheduled run. Implementation: Create a value prompt with two static choices: "Last Week" and "Custom". Let's call this parameter date_range. Create two date prompts, one for Start Date and one for End Date. Let's call these parameters start_date and end_date. Use the following expression in your query filter: ( ? d a t e _ r a n g e ?=' L a s tW e e k 'a n d [ O r d e rD a t e ]b e t w e e n_ a d d _ d a y s ( c u r r e n t _ d a t e , 7 )a n d _ a d d _ d a y s ( c u r r e n t _ d a t e , 1 ) ) O R ( ? d a t e _ r a n g e ?=' C u s t o m 'a n d [ O r d e rD a t e ]b e t w e e nc a s t ( ? s t a r t _ d a t e ? , d a t e )a n dc a s t ( ? s t a r t _ d a t e ? , d a t e ) ) The expression above will make sure that the corresponding date filter is applied depending on the selection of "Date Range". For example, when the users select "Last Week" from the value prompt, the filter will ignore what is selected in the date prompts. Now, if you want to schedule the report to run on every Monday for the past week, schedule the report and set the "Date Range" prompt value in the schedule to "Last Week" You can give any date values in the date prompts, since they will be ignored anyway. Conclusion: You can use this technique to many other cases as well. For example you can create custom groups of filter values and define your own group names. By hard coding the group members in the filter, the users will be able to select a group and

get the report that has the individual members.


Posted by Sriram at 3:50 PM 4 comments Links to this post

Tuesday, January 3, 2012

Show or Hide any Element in the Report using Javascript


Recommend this on Google

Business Case: Users want to have a list or a chart hidden in the page, which can be optionally shown/hidden. Environment: IBM Cognos 8.4.1, Internet Explorer/Mozilla Firefox, Javascript, HTML format reports. Example: I built a dashboard for a client who wanted summary level information displayed in the page with the detailed data below it, but wanted the users to be able to see detailed data only when needed. Implementation: This is a very simple task that requires only a few steps. You will need 4 HTML items for this: The first HTML item is to create a link on the page that says "Click Here to Show/Hide Item". Place this HTML item wherever you want the link Pick the element you want to show/hide and place 2 HTML items around it, one before and one after. In this example, the element I chose to hide is a value prompt. Place a fourth HTML item at the end of the page after all the elements. This will contain the main script. Your report layout should look like this:

Insert this code within the first HTML item: < ah r e f = " J a v a S c r i p t : S h o w H i d e ( ) " > C l i c kh e r et oS h o w / H i d eI t e m < / a > The second HTML item will have the following code: < s p a ni d=" v a l u e _ p r o m p t " > Place the following code in the third HTML item: < / s p a n > The <span> tag is used to create a handle for the value prompt and assign an ID to it called "value_prompt". The main script will use this handle to change the display status of the item. The last HTML item will have the main script as below: < s c r i p tl a n g u a g e = " j a v a s c r i p t " > f u n c t i o nS h o w H i d e ( ) { v a re l=d o c u m e n t . g e t E l e m e n t B y I d ( " v a l u e _ p r o m p t " ) ; i f(e l . s t y l e . d i s p l a y! =' n o n e '){ e l . s t y l e . d i s p l a y=' n o n e ' ; } e l s e{ e l . s t y l e . d i s p l a y=' ' ; } } f u n c t i o ns t a r t H i d d e n ( ) { v a re l=d o c u m e n t . g e t E l e m e n t B y I d ( " d e t a i l s " ) ; e l . s t y l e . d i s p l a y=' n o n e ' ; } < / s c r i p t > Note that in the code we are using the ID of the span to call the item. That's it.. now when you run the report, the output will look like this:

Clicking the link will hide the value prompt. Clicking it again will show the prompt. You can use this technique for toggling any element in your report. You can even use it to toggle multiple elements or an entire table. Give it a try and post your comments below. As always, I will be happy to help with any issues you have.
Posted by Sriram at 5:29 PM 11 comments Links to this post

Sunday, January 1, 2012

Validate Value Prompt using Javascript


Recommend this on Google

Business Case: Value prompts are widely used in Report Studio Reports. Users want to validate the prompt values by limiting the number of values selected at a time. Environment: IBM Cognos 8.4.1, Internet Explorer/Mozilla Firefox, Javascript.

Example: Users should be able to select only up to a maximum of 3 values. When the fourth value is selected, an alert message should be displayed. Solution: This requirement can be achieved by using javascript. When the user selects an option, the script will count the number of options selected and display an alert text when the number of selected values exceeds the user defined limit. The prompt will look like this when user selects 3 values:

When the user selects a fourth option, the "Finish" button will disappear and an alert message will be displayed, like this:

When one of the options is unselected, the "Finish" button will reappear and the alert message will be hidden. Implementation: Create the prompt page and place an alert text as above. Place three HTML items: first before the alert text, second after the alert text and the third at the end of the page after all elements, as shown below:

Place the following code in the first HTML item: < s p a ni d= " a l e r t _ m s g " > Place the following code in the second HTML item: < / s p a n > Place the following code in the third HTML item: < s c r i p t > / / C r e a t eah a n d l ef o rt h ea l e r tm e s s a g e v a ra l e r t _ m s g=d o c u m e n t . g e t E l e m e n t B y I d ( " a l e r t _ m s g " ) ; / / C r e a t eah a n d l ef o rF i n i s hb u t t o nb yg e t t i n gal i s to fe l e m e n t so nt h ep a g e w i t h" b u t t o n "t a g v a rb u t t o n s=d o c u m e n t . g e t E l e m e n t s B y T a g N a m e ( " b u t t o n " ) ; / / G e tal i s to fe l e m e n t so nt h ep a g ew i t h" s e l e c t "t a g

v a rv a l u e _ p r o m p t=d o c u m e n t . g e t E l e m e n t s B y T a g N a m e ( " s e l e c t " ) ; v a l u e _ p r o m p t [ 0 ] . o n c h a n g e=v a l i d a t e S e l e c t i o n ; / / H i d ea l e r tm e s s a g ew h e np a g el o a d s a l e r t _ m s g . s t y l e . d i s p l a y = ' n o n e ' ; f u n c t i o nv a l i d a t e S e l e c t i o n ( ) { v a rs e l e c t i o n C o u n t=0 ; f o r( i=0 ;i<v a l u e _ p r o m p t [ 0 ] . o p t i o n s . l e n g t h ;i + + ) { i f( v a l u e _ p r o m p t [ 0 ] . o p t i o n s [ i ] . s e l e c t e d ) { s e l e c t i o n C o u n t=s e l e c t i o n C o u n t+1 ; } } i f ( s e l e c t i o n C o u n t>3 ) { b u t t o n s [ 1 ] . s t y l e . d i s p l a y = ' n o n e ' ; a l e r t _ m s g . s t y l e . d i s p l a y = ' ' ; } e l s e { b u t t o n s [ 1 ] . s t y l e . d i s p l a y = ' ' ; a l e r t _ m s g . s t y l e . d i s p l a y = ' n o n e ' ; } } < / s c r i p t > That should do the trick. Now when the user runs the report, they should see an alert when selecting more than 3 options. Test it out and post your comments. You can also contact me through email at cognosonsteroids@hotmail.com
Posted by Sriram at 4:03 PM 2 comments

Newer Posts Subscribe to: Posts (Atom)

Home

Older Posts

Popular Posts

Create a Report with Collapsible Hierarchy Keywords: Collapsible Hierarchies OR Expandable List Report OR Tree Structured Report Business Case: Collapsible hierarchies are usef...

Crosstab with Non-Numeric Fact Business Case: The user wants to display the data in a crosstab format but the values in the intersection are not numeric. Example 1: U...

Show or Hide Date Prompts based on Radio Button Selection Keywords: Date Prompt - Show or Hide - Radio Button - Javascript - Report Studio - Cognos 8 Business Case: Many a times, you may want...

Show or Hide List Report Columns using Javascript Business Case: Report author wants to create a list report in, which, any of the columns can be shown/hidden after the report execution is...

Clear Value Prompt Selections Using Javascript Business Case: User wants a clickable link on the prompt page to clear all prompt selections. Environment: Cognos 8.4, Report Studio, Ja...

Simple template. Powered by Blogger.

You might also like