COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: vijaypamidi on 04 Jun 2009 05:02:49 AM

Title: Java script needed to validate 2 date prompts.
Post by: vijaypamidi on 04 Jun 2009 05:02:49 AM
Hi,

I have 2 date prompts in my Report
Start Date,End date
If the user selects Start date> End Date then
a pop message should Popup saying
'Please select start date lessthan End date'

Thanks,
Vijay.P
Title: Re: Java script needed to validate 2 date prompts.
Post by: Shailaja0520 on 30 Jun 2009 01:33:49 AM
<script>
function customCheckPage(){
var par1;
var par2;
for( var i=0; i<preProcessControlArray.length; i++){
  cntlName = eval(preProcessControlArray);
  if ( cntlName.m_oSubmit.name.toLowerCase() == 'p_paramater name for start date'){
   par1 = cntlName.m_oForm.value;   
   eval('pickerControl' + cntlName.m_sRef + '.lostFocus()');
  }
  if ( cntlName.m_oSubmit.name.toLowerCase() == 'p_paramater name for end date'){
   par2 = cntlName.m_oForm.value;   
   eval('pickerControl' + cntlName.m_sRef + '.lostFocus()');
  }
}
  if (par1<=par2)
    promptButtonFinish();
  else
    alert('Start Date must be less than or equal to End Date !');
}
for( var i=0; i<pageNavigationObserverArray.length; i++){
  cntlName = eval( pageNavigationObserverArray );
  if(cntlName.m_oParent.onclick.toString().indexOf('promptButtonFinish()')>0 ){
    cntlName.m_oParent.onclick = customCheckPage;
  }
}
</script>
Title: Re: Java script needed to validate 2 date prompts.
Post by: david.stachon on 01 Jul 2009 10:28:24 PM
....if it were me, I wouldn't do this with 2 prompts/parameters.

Use:

[my date] in_range ?p my_date?

...this will then generate the date range prompt object.

Unfortunately, it still won't stop a user from entering a "from date" that's greater than your "to date" ....but seriously, is it worth a whole load of extra code to prevent a user from doing this?
Title: Re: Java script needed to validate 2 date prompts.
Post by: Shailaja0520 on 11 Aug 2009 04:47:46 AM
Hi Can u help in this --
help me out in knowing how to initialize a date Range prompt.

Let me explain the scenario..

I have a drill through report. I have a date range prompt in the child report assigned to a parameter say ?P1?

Now I am suppose to pass a value to this parameter ?P1?

Note:
1. I am not suppose to make any change to the child report.
2. In the parent report I have three kind of prompts:
    Two date prompts- for start date and End Date(enabled only when my time bucket selected is Daily)
    Two value prompts- For week start date and week end date ( enabled only when my time bucket selected is weekly)
    Two value prompts- for start month and end Month(enabled only when my time bucket selected is Monthly)