This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Apr 24, 2012, 6:52 AM
11 Posts
topic has been resolvedResolved

Xpage Validation(Date Time Stamp) & Order of Evaluation

  • Category: Server Side JavaScript
  • Platform: Windows
  • Release: 8.5.1
  • Role: Developer
  • Tags: Xpage Validation
  • Replies: 2

if((!submittedBy( 'button1' )) && (!submittedBy( 'button2' )))

{

return true;

}

else

{

var IsL2UserTxt = sessionScope.get("IsL2User");

if(IsL2UserTxt == "Yes")

{

 

//Bring the issue Date&Time

var start = getComponent("label_IssueDateDt").getValue();

//Bring the Permenent Fix Target Date&Time

var end = this.getSubmittedValue();

var dStart:NotesDateTime = session.createDateTime(start);

var dEnd:NotesDateTime = session.createDateTime(end);

if (!start)

{

return false;

}

else if (!end)

{

return false;

}

else

{

print("Start: "+start+", End: "+end+",DStart: "+dStart+", DEnd: "+dEnd+", Time Diff: "+dEnd.timeDifference(dStart));

return (dEnd.timeDifference(dStart) > 0 )

}

}

else

{

return true;

}

}

 
 
I have two Date Timestamp editbox in xpage, I written a validateExpression code as shown above for on my second datetime stamp(Permenent Fix tartget Date&Time) editbox. Here validation is required such a way that permaenent fix Target date&Time should be greater that Issue date&time( dEnd.timeDifference(dStart) > 0 ).
 
The above code works in scenario such that, if issue date is  24/04/2012 11:16:51 AM and permaenent fix Target date&Time 23/04/2012 11:16:51 AM . But it fails if my permaenent fix Target date&Time is between 05/04/2012 to 12/04/2012. I think there is problem with date time formats as the submitted value of the permaenent fix Target date is coming like this e.g 2012-04-12T11:16:45+05:30.
 
So is there any solution to format date time value of the submitted value to avoide above issue.
 
One more thing about the order of evaluation of validation in xpages.. As validation error message control showing messages randomly not in proper orgder.  
 
Looking for your positive responses. 
 
Regards, 
Yogesh  

Apr 25, 2012, 3:52 PM
17 Posts
Re: Xpage Validation(Date Time Stamp) & Order of Evaluation
 Below is the code for validation of date & time components:
 
var doValidate = (submittedBy( 'button1' ) || submittedBy( 'button2' )) && (sessionScope.get("IsL2User") == "Yes");
if (!doValidate) return true;
var dtIssue = getComponent("label_IssueDateDt").getSubmittedValue();
var dtPermFix =  this.getSubmittedValue();
if ( (dtIssue == null) || (dtPermFix == null) ) return false;
var difference = I18n.parseDateXMI(dtPermFix) - I18n.parseDateXMI(dtIssue);
return difference > 0;
 
It may be possible to sort the error messages. But i never tried it. 
Apr 27, 2012, 12:09 PM
11 Posts
Re: Xpage Validation(Date Time Stamp) & Order of Evaluation
Issue has been resolved as getsubmitted value returns text. I just converted that text value to date as follows:
var endoldFixDateDt =getComponent("Label_immediateFixDateDt").getSubmittedValue();
var endFixDateDt = @TextToTime(endoldFixDateDt);
var dEndFixDateDt:NotesDateTime = session.createDateTime(endFixDateDt);
 
Thanks for your reply, I tried it, it's also working.
Regards, Yogesh

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal