COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: hrk551 on 11 Mar 2009 08:21:21 AM

Title: To Dynamically display first item in a value prompt and to run that parameter
Post by: hrk551 on 11 Mar 2009 08:21:21 AM
Hello,
Can some one help me out ..... My requirement is to dynamically display  the first item in the value prompt and to run that parameter. I am using Cognos 8.3. and I am NOT using any prompt page.

I tried using the following script, with this I am able to display the first item but its not taking that parameter.. instead its taking  the whole data.

<script type="text/javascript">
function init()
{

if

(document.formWarpRequest._oLstChoicesPeriode.options[3].selected == false)

{

if

(document.formWarpRequest._oLstChoicesPeriode.options[2].selected == false)

{

document.formWarpRequest._oLstChoicesPeriode.options[2].selected = true;

listBoxPeriode.autoSubmit();

}

}

}
</script>
<body onLoad=init()>


Thanks....
Title: Re: To Dynamically display first item in a value prompt and to run that parameter
Post by: rockytopmark on 11 Mar 2009 10:42:10 AM
That Javascript will only work in Cognos version 8.2 or earlier.  Cognos made significant changes to how objects are referenced in 8.3, thus many broken Cognos reports using Javascript when created in earlier versions and upgraded to 8.3.  All is not lost.. there are new ways. 

Here is an Exceprt from the Cognos Document outlining the Cognos 8.3 and up usage of various Javascript functions:

autoSubmit( ) Function Replaced
The autoSubmit( ) function no longer exists, having been replaced by the
promptButtonFinish( ) or promptAction(‘finish’) function. References to the
autoSubmit( ) button must be replaced with the new function.
For an example, refer to Knowledge Base (KB) article:
1012254 – JavaScript: Set default value for a value prompt by using HTML
item
A bulk search/replace utility such as DRU may be useful to deal with this
issue.

Log into the Cognos Support site and search this KB article. 

The link to the whole document is:
http://support.cognos.com/en/support/diagnostics/pdf/upgrading_javascript_applications.pdf
Title: Re: To Dynamically display first item in a value prompt and to run that parameter
Post by: cognosvg on 12 Mar 2009 02:49:25 PM
Hi,
We have 8.2 if I use the script:
<script type="text/javascript">
function init()
{

if

(document.formWarpRequest._oLstChoicesPeriode.options[3].selected == false)

{

if

(document.formWarpRequest._oLstChoicesPeriode.options[2].selected == false)

{

document.formWarpRequest._oLstChoicesPeriode.options[2].selected = true;

listBoxPeriode.autoSubmit();

}

}

}
</script>
<body onLoad=init()>

it works but its only the first value all the time. If I choose second value or third value it filters back on the first value again..

I tried using just this:
document.formWarpRequest._oLstChoicesPeriode.options[2].selected = true;

listBoxPeriode.autoSubmit();

report refreshes after every 2 seconds or so.

Please let me know if you have the right script.

Thanks..
Title: Re: To Dynamically display first item in a value prompt and to run that parameter
Post by: hrk551 on 12 Mar 2009 03:23:41 PM
Thats the same problem with me also dude.... let me know if you find a way
Title: Re: To Dynamically display first item in a value prompt and to run that paramete
Post by: rockytopmark on 13 Mar 2009 05:00:31 PM
I used the Cognos document to solve a similar problem in 8.3 ... worked like a champ.

Link to the document is in my earlier post.
Title: Re: To Dynamically display first item in a value prompt and to run that parameter
Post by: cognosvg on 15 Mar 2009 08:44:44 PM
Hi,
Do you have the similar script for 8.2?

Thanks in advance.
Title: Re: To Dynamically display first item in a value prompt and to run that parameter
Post by: hrk551 on 16 Mar 2009 01:24:31 PM
Hi Rocky,

with  reference  to Knowledge Base (KB) article:
1012254 â€" JavaScript: Set default value for a value prompt by using HTML item,

I applied the following Javascript to my report:
For Cognos 8.3

<script language="javascript">
if (getFormWarpRequest()._oLstChoices<FieldName>.length ==1)
{
getFormWarpRequest()._oLstChoices<FieldName>.selectedIndex = 0;
if (getFormWarpRequest().elements["cv.id"].value == "RS")
     setTimeout('oCVRS.promptAction(\'finish\')', 100);
else
    setTimeout('oCV_NS_.promptAction(\'finish\')', 100);
}
</script>


and the Result is : its displaying the first value in the drop down list correctly,but its not displaying data for that particular month instaed its showing the whole data i:e ... its displaying 200812 and the data is displayed for all the months in 2008. Which did not solve my problem. Can anyone help me out .... I got 5 Reports with the same requirement,so its important for me to solve this issue.

Title: Re: To Dynamically display first item in a value prompt and to run that parameter
Post by: hrk551 on 27 Mar 2009 09:06:46 AM
Any Solutionsss!!!!!!!