COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: RiRo on 11 Dec 2013 03:25:53 AM

Title: Dynamic Prompt with default value
Post by: RiRo on 11 Dec 2013 03:25:53 AM
Hi

I use a prompt to choose a reportperiode for a Report, which is in this Format 'yyyy-mm'.
I can manually select this values and the Report works fine.

So now I want to schedule this Report, so that users get the Report automatically.
So I have to assign a Default value, which is the last or better the next to last Periode.

How can I make this?

Thanks
Rob
Title: Re: Dynamic Prompt with default value
Post by: MFGF on 13 Dec 2013 11:11:49 AM
Change the prompt to a filter that is not prompted - that's the easy way :)

MF.
Title: Re: Dynamic Prompt with default value
Post by: RAHIOUI on 23 Dec 2013 04:36:23 AM
Hi Riro,

1.  Select the value prompt and defne its sorting such that the Shipment Month Keys
are populated in descending order.
2.  Now, as we know the dimension is always populated up to the current month and
values are sorted in descending order, we will write a code that selects second value
from top by default.
3.  For that, add an HTML Item just before the Shipment Month value prompt. Defne the
HTML as: <span id = 'A1'>
4.  Add another HTML item just after the value prompt and defne it as: </span>
5.  Now add another HTML item to the prompt page footer, just after the Finish button.
6.  Defne it as:
<script>
var theSpan = document.getElementById("A1");
var a = theSpan.getElementsByTagName("select");   /* This stmt
return an array of all value prompts within span */
for( var i = a.length-1; i >= 0; i-- )  /* now loop through the
elements */
{   var prompts = a;
if( prompts.id.match(/PRMT_SV_/))
{  prompts.selectedIndex = 3;  } /* This selects the second
options from top */
canSubmitPrompt();
}
</script>
7.  Execute the report to test it.