If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Default selection in the value prompt

Started by Anand, 04 May 2008 08:17:06 AM

Previous topic - Next topic

Anand

Hi All,
How to get dynamic max year(ex:2008) as default selection in the value prompt when i run the report.

Regards,
Anand.

kattaviz

Hi,
U can do that using javascript. Get the values from listbox in a array and sort the array elements. Once u got the max value from array assign that value to listbox selected item. Please let me know if u need more info.
I can post the code tomorrow if u want.


HTH
thanks

thanks & regards
Satish Katta

Anand

Hi Satish,
Thanks for sending the reply and i am displaying that value prompt in the report page itself and they are in sorting order only(2006,2007,2008,2009,2010) and please send me the java script and when i run the report it should display by current year and after that we can change that from the prompt available in the report header.

Regards,
Anand.

kattaviz

Hi Anand,

Please see the following script for ur solution.

---------------
var lb = document.getElementById('formWarpRequestRS')._oLstChoicesXXX;
arrTexts = new Array();
for(i=0; i<lb.length; i++)  {
  arrTexts = lb.options.text;
}
arrTexts.sort();
var len=arrTexts.length-1;
document.getElementById('formWarpRequestRS')._oLstChoicesXXX.options[len].selected=true;

---------------

Where XXX is the name of the Value prompt. Sorry for the delay. I was travelling and did not access the forum.
thanks & regards
Satish Katta

kattaviz

Quote from: kattaviz on 20 May 2008 02:59:11 PM
Hi Anand,

Please see the following script for ur solution.

---------------
var lb = document.getElementById('formWarpRequestRS')._oLstChoicesXXX;
arrTexts = new Array();
for(i=0; i<lb.length; i++)  {
  arrTexts = lb.options.text;
}
arrTexts.sort();
var len=arrTexts.length-1;
document.getElementById('formWarpRequestRS')._oLstChoicesXXX.options[len].selected=true;

---------------

Where XXX is the name of the Value prompt. Sorry for the delay. I was travelling and did not access the forum.
If u already sort the query for the prompt then u do not need to sort the array in javascript code. remove the line "arrTexts.sort();"
thanks & regards
Satish Katta

almeids

And if you sort descending you don't need any logic to determine the list size, just select the first element.

chris2001dc

Hi,

Does the javascript code posted here works in Cognos 8.3??

Thanks