COGNOiSe.com - The IBM Cognos Community

IBM Cognos Analytics Platform => Cognos Analytics => Reporting => Topic started by: sukanya on 07 Jul 2017 03:06:36 PM

Title: Default Date for Prompt
Post by: sukanya on 07 Jul 2017 03:06:36 PM
Hi,
I am trying to use below JS in HTML item with cognos 11.0.6. Its not setting the default date to current date. I did made the interactivity to No.

<script language="javascript">
var dDate = new Date();
//Subtract one day
dDate.setDate(dDate.getDate());
pickerControlStartDateParam.setValue(getFormatDate(dDate, 0 , 'YMD'));
</script>

Question: When it sets default current date, does the prompt show it as prompt header value and filters the report?

Regards,
Sukanya
Title: Re: Default Date for Prompt
Post by: CognosPaul on 19 Jul 2017 04:51:01 PM
You really should be using the prompt API for this. That picker syntax is from 8.4.

<script>
var paulScripts ={}
  , oCR = cognos.Report.getReport("_THIS_");

paulScripts.getControl = function(promptName) {
  return oCR.prompt.getControlByName(promptName);
};

paulScripts.getControl('StartDate').setValues([{'use':'2017-01-01'}]);
</script>


Date prompt controls in Cognos always default to today. Are you talking about the prompt in the filter?