COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: nagababu on 23 Aug 2012 12:24:01 PM

Title: hi experts in report studio dynamic prompt selection issue
Post by: nagababu on 23 Aug 2012 12:24:01 PM
Ihave two value prompts on year.like from year and toyear with 10 years data on both prompts based on fromyear selection need to be select in second prompt.example if iselect 2011 in from year automatically default value 2011 need to be select in second prompt I.e,toyear
Title: Re: hi experts in report studio dynamic prompt selection issue
Post by: tjohnson3050 on 23 Aug 2012 12:53:33 PM
Cognos Report Studio does not give the ability to make a dynamic default prompt selection.

It can be done with javascript (some better at it than me may want to post).

What you can do is make a the first prompt filter the second prompt, so that choosing 2011 on the first prompt filters out 2010 and earlier years from the selection list in the second prompt.
Title: Re: hi experts in report studio dynamic prompt selection issue
Post by: CognosPaul on 23 Aug 2012 01:52:18 PM
If I understand the requirements, you have two year value prompts. Both are based on the same query, both show the same set of years, one is fromYear and one is toYear.

You need to have the fromYear change whenever a different year in the toYear is selected?

Try this (may not working perfectly, doing it from memory):

First, name both prompts "_fromYear" and "_toYear".
Second, paste this into an HTML after the prompts:

<script>
var fW = (typeof getFormWarpRequest == "function" ? getFormWarpRequest() : document.forms["formWarpRequest"]);
if ( !fW || fW == undefined) 
{

    fW = ( formWarpRequest_THIS_ ? formWarpRequest_THIS_ : formWarpRequest_NS_ );

}

fW._oLstChoices_toYear.onChange = new Function ("fW._oLstChoices_fromYear.selectedIndex = fW._oLstChoices_toYear.selectedIndex");
</script>


If my memory is correct (no guarantees, I don't have Cognos to check it at the moment), this will meet your needs as I understand them.
Title: Re: hi experts in report studio dynamic prompt selection issue
Post by: nagababu on 27 Aug 2012 05:45:24 AM
Thanks for your replies.I tried with that java script.but its not working.

Is there any way Auto selection in the first value in the prompt.

Actually for the above senario,iam able to get selected values comes first in the second prompt.

but auto selection only the main problem,i have used cascade prompt fromyear and toyear
Title: Re: hi experts in report studio dynamic prompt selection issue
Post by: nagababu on 28 Aug 2012 04:52:15 AM
thanks every one , i have achived the above required prompt selection by using below mentioned java script.

<script language="javascript">
var f = getFormWarpRequest();
var list = f._oLstChoicesPrompt1;

list.remove(1);
list.remove(0);
list.removeAttribute("hasLabel");
list.options[0].selected = true;

</script>