Question

Custom Edit Validate

I have following requirements:

1. Creating Edit validate rule and comparing 2 dates using java code. The 2 dates are properties in application. I am unable to use other property in Edit validate rule( as 1 property can be used as 'theValue')

2. the 2 dates are in a pagelist for ex pyWorkPage.TestPage (every page in list contain 2 dates) whic needs to be compared in the edit validate rule.So my question is will this edit validate rule work in a repeating grid if not how can i address this requirement.

Below is my custom edit validate:

if (theValue.trim().length() == 0) {

return false;

}

java.util.Date theDate = tools.getDateTimeUtils().parseDateTimeString(theValue);

return (theDate != null && theDate.after(NEED THE OTHER DATE PROPERTY HERE);

Thasks alot in advance!!

Comments

Keep up to date on this post and subscribe to comments

Pega
May 22, 2019 - 1:43pm

If you have access to the Customer Service application, there is a rule-edit-validate called CAIsStartTimeLessthanEndTime.  I believe it does something similar to what you want.  Here is the body of that rule if you don't have access:

ClipboardPage page = tools.findPage("pyWorkPage");

String startDate = page.getProperty(".StartDate").getStringValue();
String endDate= page.getProperty(".EndDate").getStringValue();

java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyyddmm");
 
try
{
     java.util.Date startdate = sdf.parse(startDate);
     java.util.Date enddate = sdf.parse(endDate);
     if(startdate.compareTo(enddate) != 0)       
        return true;
    else
    {

       String startTime = page.getProperty(".StartTime").getStringValue();
       String endTime= page.getProperty(".EndTime").getStringValue();

       int st = java.lang.Integer.parseInt(startTime);
       int et = java.lang.Integer.parseInt(endTime);

       if ( st >= et )
           return false;
       else
           return true;
    }
}
catch(Exception e)
{
     return false;
}