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

 

To Dynamically display first item in a value prompt and to run that parameter

Started by hrk551, 11 Mar 2009 08:21:21 AM

Previous topic - Next topic

hrk551

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....

rockytopmark

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

cognosvg

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..

hrk551

Thats the same problem with me also dude.... let me know if you find a way

rockytopmark

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.

cognosvg


hrk551

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.