Discussion

Can someone guide me on how to create an Edit Validate rule to find the difference in days b/w 2 given dates

I have a custom filter section  included in Report Definition rule, need to Validate two date fields to find the difference in days between the dates entered ( < 60 days), if i use OnChange Activity its works fine for the for the Custom filter section rendered, but when we choose the advance filter option, it fails to throw the message , the only option left is to write an Edit Validate rule , but the Edit validate rule is not performing as expected, could someone guide me on the same

Edit Validate Code is below :

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

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

java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy/MM/dd HH:mm:ss");

try{
   java.util.Date startdate = sdf.parse(startDate);
   java.util.Date enddate = sdf.parse(endDate);
   long startTime = startdate.getTime();
   long endTime = enddate.getTime();
   long diffTime = endTime - startTime;
   long diffDays = diffTime / (1000 * 60 * 60 * 24);

   int diffe = pega_rules_businesscalendar.differenceBetweenDays(endDate, startDate, true, "");
 

   if(diffe < 60)        
      return false;
    }
catch(Exception e){
      return false;
 }
  

return true;

 

 

**Moderation Team has archived post**

This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.

Comments

Keep up to date on this post and subscribe to comments

January 9, 2016 - 9:07pm

Hi Sheeba,

We also have the same requirement. Can you tell me how you are validating date range? using custum button or on the date picker. If you are using custom button how to hide default report definition submit button, which is not having any I'd value