Thursday, April 1, 2010

Custom Calendar / Date prompt Control in Cognos

How many times have there been requirements to make the Date Prompt behave in a manner that it is not programmed to do so? I was stumped with a similar such requirement recently.

The requirement was to have the date prompt default to the corresponding Saturday's date if the user selected a week date or even better to disable all weekdays in the date prompt.

Now any Cognos developer would agree with me that this is impossible to achieve using the default Cognos Date prompt. Agreed and I even tried reasoning with the clients but to no avail. They were already aware that Cognos allowed JavaScript to be written and so they were adamant in their requirement. Though Cognos allows JavaScript it is not meant to be misused so much. Anyway, I cautioned them about upgrade issues, non-support of JavaScript by Cognos and got to work.

For those of you with such requirements the best would be to get a Custom Drop Down Calendar Script from the innumerable Java sites and paste the same in a HTML item in your report and you are good to go.

I did the same.

  • Found a good to use calendar prompt and included the same in my Cognos report.

  • Modified the code to handle my weird scenarios.

  • Created a HTML submit button and a hidden text box prompt.

  • Wrote a script behind the Submit button to populate the hidden text box prompt with the selected date value and submit the report to Cognos.

2 comments:

eejimkos said...

hi.....

i am new in cognos and i would like your help....

i hava a cognos cube as a package and i want from a calendar to choose a period of time for my report...

tnks in advance

Zephyr said...

Create a calculated Set - filter([Date], [Date] >= ?From Date? and [Date] <= ?To Date?)

where [Date] is a data item inside your Time Dimension at the Date level.