Custom Search

Tuesday, June 10, 2008

Cognos 8- Java Script for Date Validation

If data range needs to be passed for any Report studio report, 2 date prompts are required.
If user should not be allowed to 'Run' the report if period begin date is greater than period end date, then follow below listed steps.

Steps-


1. Give name 'txt_o_b_dt' to the date prompt which belong to period begin date.
(Shown in italics in below java script)

2. Give name 'txt_o_e_dt' to the date prompt which belong to period end date.
(Shown in italics in below java script)

3. Drag an HTML item to the footer of the prompt page.

4. Paste below java script in to that.


var bgn_dt= new Date(document.formWarpRequest.txtDatetxt_o_b_dt.value);

var end_dt= new Date(document.formWarpRequest.txtDatetxt_o_e_dt.value);

if (bgn_dt>end_dt)

alert("End date should be greater than Begin date.");

else
{
promptButtonFinish();
}

Here values from the date prompts(those are of string type) are converted into date type and stored in 2 variables- bgn_dt and end_dt.

If bgn_dt>end_dt and user clicks on Finish or Next button, he will get a message box saying that selection is wrong.

Only after making right selection he will be allowed to run the report or move to the next page.

5 comments:

rocky said...

I have followed every step as mentioned. But validation is done when prompt is loaded not when To date is selected.

How to do validation after end date is selected.
I am selecting start date and end date from prompt. After selection, I need validation.

PhOne!X said...

Hi,
I have 3 cascaded prompts on report page.since its on report page(User requirement), the whole report runs after changing value for prompts. Using Java Script can we update only the prompts and restrict report from running until we click on Finish Button
Thanks

nilesh kirve said...
This comment has been removed by the author.
nilesh kirve said...

I tried same one but It doesn't work on FM.

(FYI:I am using framework manager version 8.4)


any help will be more appreciated.

regards,
Nilesh.

nilesh kirve said...
This comment has been removed by the author.