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

Need Javascript for date range prompts in Cognos 8.4/10.1

Started by fshahul, 28 Aug 2012 12:25:34 AM

Previous topic - Next topic

fshahul

Hi,
I am having 3 prompts in my prompt page as below.
1. Frequency, Default value: Monthly, Quarterly, Yearly, Lifetime
2. Start Date, Default value: Current Date
3. End Date, Default value: Current Date
Based on the selection as Monthly , Quaterly  and yearly , validation needs to happen between from and to dates after clicking on the submit button  and  needs to throw a message if it fails.
If monthly then difference between from and to date should be 30 or 31 days ,similarly for quarterly 90 or 3 months  duration, and similarly yearly 365 days . 

I need a javascript for this which supports on both 8.4 and 10.1 version. Anyone help on this.

Very Urgent.

Thanks.

fshahul

Monthly - The script should not allow more than 30 days in the date range
Quarterly - The script should not allow more than 90 days in the date range
Yearly - The script should not allow more than 365 days in the date range
Lifetime - The script should  allow 'n' of  days in the date range.

Its very urgent requirement. Can anyone help me on this?

Lynn

This is a strange prompting requirement...maybe if I saw the whole thing it would make more sense, but why prompt for frequency in addition to both start and end date? Wouldn't it be easier for the user if they picked a frequency and a start date and let the report compute the end date using _add_months or _add_years function? I especially like the 365 day validation for the yearly frequency which conveniently ignores leap years  :o

Lifetime sounds more like a free-form date range but it isn't even referenced in your requirement snippet.

Talking sense to business analysts can sometimes be a slippery slope, so if you must implement this cumbersome approach I suggest you implement it without java script. I would create variables to interrogate the prompt selections so you can conditionally render either the report page per their selections or else an error page indicating they've messed it up.

P.S. Make sure the error page is attractive because I suspect they'll be seeing it a lot trying to get the right start and end dates  ;)


CognosPaul

I agree with Lynn on this. Finding a non-JavaScript solution is preferable. I have a client that has hundreds of reports with JavaScript. They're moving from 8.2 to 10.1. Each and every report has to be checked and fixed because of all the JavaScript. And since the people that wrote the JS in the first place are no longer with that company, the upgrade process is going extremely slowly.

Maybe set the validation in the filter, something like;

[Date] <= ?End Date? and
[Date] >=
case ?Frequency?
when 'Monthly' then case when _days_between(?Start Date?,?End Date?)>30 then _add_days(-30, ?End Date?) else ?Start Date? end
when 'Quarterly' then ....
end


If you do need to do this in JavaScript, then you'll need to reset the onclick event of the finish button, which is messy business.

fshahul

Hi Lynn and Paul,
Thanks for your quick reply. Could you please explain me step by step the process and provide me the complete code, if possible.

Thanks in advance.

Lynn

Quote from: fshahul on 29 Aug 2012 12:40:51 AM
Hi Lynn and Paul,
Thanks for your quick reply. Could you please explain me step by step the process and provide me the complete code, if possible.

Thanks in advance.

Paul and I provided some different alternatives for you. You'll need to decide how you want to go about implementing it. Give it a try and post back with any specific questions you have.