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

Display selected date in date prompt

Started by HDA, 06 Jan 2014 11:27:53 AM

Previous topic - Next topic

HDA

I have a Date prompt on Report page. I added a html script to make yesterday's date as default value.

When a user changes the date, the report refreshes with data corresponding to the date changed. But the display value for the prompt comes back to the default value(yesterday's date). Which means report is showing data for the date selected but the prompt on top of the page always displays yesterday's date.

How can we change the prompt to display whatever user selects ? I still want Yesterday's date to be default because that is what I need to display when the report runs first time.


adik

How does you code for setting the prompt to a default date look like? Is if via javascript of other technique?

adik

#2
anyway...regardless of what you are using I would go about this (this is for Cognos 10.2):

1. create a prompt page
1. place a Text Prompt Box on the prompt page and name it HiddenDatePrompt
3. put two html items from the tool box, one to the left and one to the right of the value prompt
3.1 in the one to the left place the following code:

<span style="display: none;">

3.2 in the one to the right place the following code:

</span>

<script>
function setDefaultDate()
{
var oCR = cognos.Report.getReport("_THIS_");
var hiddenDatePrompt = oCR.prompt.getControlByName("HiddenDatePrompt");

var defaultDate= new Date();
defaultDate.setDate(defaultDate.getDate() - 1);

pad = "00";
var day = (pad + defaultDate.getDate()).slice(-pad.length);
var month = (pad + defaultDate.getMonth() + 1).slice(-pad.length);
var year = defaultDate.getFullYear();
var defaultDateFormated = day + "." + month + "." + year;

hiddenDatePrompt.addValues([{"use": defaultDateFormated, "display": defaultDateFormated }]);

setTimeout("promptButtonNext();", 100);
};

setDefaultDate();
</script>

4. on your report page place a value prompt
5. select Use existing parameter and select the same parameter as defined on the prompt page
6. set the Autosubmit to Yes

and that's it

PS: my query item that has the dates in it returned the date in the following format DD.MM.YYYY
that is why in the javascript i converted the date to the same format, they have to match, and of cource the value returned by the java script must also exist in the values of the query feeding the value prompt

navissar

The problem is that your script works even after you set the date. You want to add in to the code a verification mechanism which ensures that the default value is only put in once.