When do you want the expression to fire? You would need to use "Whenever Used" and current date time to be accurate at all times but that may lead to inconsistencies. Perhaps the age should be based on a fixed date such a person's age on the date that a claim was filed? If the second date is fixed then you can use "Whenever inputs change".
The logic for computing human age is not solved by rounding down i.e., using floor(), after dividing by the number of days in a year since every 4th year has 366 days not 365. Instead the logic for computing human age is as follows:
Year1 = year(date1), Year2 = year(date2), DayOfYear1 = dayofyear(date1), DayOfYear2 = dayofyear(2)
YearDiff = Year2 - Year1
ExtraYear = IF (Year2 != Year1 AND DayOfYear2 >= DayOfYear1 ) THEN 1 ELSE 0
Age = YearDiff + ExtraYear
The logic above assumes Year2 >= Year1. You can use Functions in the DateTime Library for year() and dayofyear().
Posted: 4 years ago
Posted: 28 Jun 2016 22:57 EDT
Abhijith Kolanakuduru (Abhijith_CLSA_v62)
Pega Certified Lead System Architect
Use "When used if no value present" in Change Tracking tab. So that it'll get calculated only once. This will Compute when the value is null, blank, zero, or does not yet appear on the page using backward chaining. Assuming the computation results are not null, later requests for the target property do not cause the Declare Expression rule to run.