Hi Gurus,
I am using Cognos 10.2.2 and relational model. We have a requirement where we have a date prompts with Edit box (From Date and End Date). We have defined 'From Date' date prompt with a default static choice as 'Jan 1, 2015', 'End Date' by default current date.
We wanted 'From Date' date prompt default value has to be changed based on the year change. I know, we don't have any other option other than java script, where we need to define the default value of 'From Date' using a java script, which could be dynamic and change based on the year change.
Current Output:
From Date: Jan 1, 2015
Expected Output:
From Date: Jan 1, 2016
Say suppose current year is 2014, then 'From Date' should be Jan 1, 2014, if the current year changes to 2015, then 'From Date' should be changed to Jan 1, 2015. If the current year is 2016, then 'From Date' should be changed to Jan 1, 2016 and so on.
Can someone suggest me or guide me the java script or other solution.
Your help is much appreciated.
Thanks & Regards,
XYZ
Hi All,
I got the java script to set the default date of Jan 1st to the date prompt for the current system year. I have one issue here with the java script, whenever I change the From Date date prompt and press Finish button then the java script for the 'From Date' date prompt is setting it to default value, instead of the selected value and 'Finish' the report. As the page is getting refreshed.
Date prompt UI: Edit Box, Calendar Type: Georgain
Date prompt name property: bdcs_Date
<script>
var strtdt= new Date();
strtdt.setDate(1);
strtdt.setMonth(0); //January is 0!
strtdt.getFullYear();
pickerControlbdcs_Date.setValue(getFormatDate(strtdt, 0, 'MDY'));
</script>
Can someone please let me know your suggestions/comments on the same.
Thanks & Regards,
XYZ
I've got no experience with JavaScript I'm afraid, but I would imagine you'd only want your script to run when your page loads rather than when it refreshes...I'll bow out now :)
Hi BigChris,
Thanks for the prompt reply.
I am also not a java script guy :(.
Can someone please help me on my scenario with below java script.
<script>
var strtdt= new Date();
strtdt.setDate(1);
strtdt.setMonth(0); //January is 0!
strtdt.getFullYear();
pickerControlbdcs_Date.setValue(getFormatDate(strtdt, 0, 'MDY'));
</script>
Your help is much appreciated :)
Thanks & Regards,
XYZ