COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: actcognosuser on 20 May 2016 10:56:56 AM

Title: Javascript for re prompt functionality for default date prompt
Post by: actcognosuser on 20 May 2016 10:56:56 AM
Hello Cognos Experts,

I have defaulted my date prompt to previous day and have a prompt macro to filter the  data in list for the same date.
When the report is run by default previous day is highlighted in the dateprompt. When User selects a different date and
clicks finish, report runs for the selected date - But on the date prompt instead of showing the selected date , the default date is highlighted.

Is there a javascript to use to highlight selected date?

Below is the code I am using to default to previous day.

<script> function Yesterday() { var ndays = 1;
var dtToday = new Date();
var dtYesterday = new Date( dtToday - (86400000*ndays));
var strYesterday = [dtYesterday.getUTCFullYear(), dtYesterday.getMonth()+1, dtYesterday.getDate()].join("-");
return strYesterday; }
pickerControlPDate.setValue(Yesterday() ); </script>
Title: Re: Javascript for re prompt functionality for default date prompt
Post by: dougp on 20 May 2016 04:52:18 PM
The JavaScript will always set the value of the date prompt.

Did you skip a step in the description of the user's process?

1.  User opens the report
2.  The prompt page appears and JavaScript sets the default date
3.  User selects a different date and clicks Finish.
4.  Report displays
5.  User runs the report (by clicking on the Run button in the report toolbar while viewing the report?)  (I think this is the step you left out.)
6.  The prompt page appears and JavaScript sets the default date.  <-- This is where the date should be the one the user selected.

If that's the completed scenario, you'll need to store the user-selected date somewhere.  Since a date prompt always defaults to the current date, I recommend a hidden textbox prompt.  The value can be [blank] when the prompt page loads the first time.  On Finish, JavaScript should set the value of the textbox equal to the value of the date prompt.  When the prompt page loads again, JavaScript should inspect the textbox to determine how to set the value of the date prompt.