FindMaxDateInRFs( )
Find the maximum value of the given date, date-time, or partial-date items in all of the repeating instances of the form identified by the form ID. This function is only applicable to date fields.
Note:
This rule helper function is not supported for use in Screen Candidate rule execution.Syntax
FindMaxDateInRFs('variable', DateMask)Parameters
Note:
It is allowed to reuse variables passed into this function elsewhere in the rule expression, however you must add the variable as a parameter using single quotes.| Parameter | Required or Optional | Description |
|---|---|---|
variable |
Required | Item variable to search, passed in using single quotes. |
DateMask |
Optional | Flag to specify how partial dates should be handled:
Note: Use mask only for date elements and do not use it for time elements. Any missing value in the time part is considered as 00. |
Return value
- Maximum date value in String format. For example,
'27-Jan-2021 00:00'. nullif maximum is not found.
Usage tips
- Use
'DD-MON'format as DateMask to substitute unknown (UNK) values in the partial date values. For example, if the mask is'01-MAR':Partial date value Masked date Notes 'UNK-FEB-2020''01-FEB-2020'Made effective for calculation using the day part of the mask. 'UNK-UNK-2020''01-MAR-2020'Made effective for calculation using both, the day and month parts of the mask. - To convert return value to JavaScript date object, extra formatting should be done.
For
example:
vExample = '10-Jul-2022 10:UNK:UNK' new Date(vExample.replace(/UNK/g, "00"))
Examples
Example 3-48
// Get the maximum date value for an item across a set of repeating form instances
return FindMaxDateInRFs('aeDate');
// Same as above, using a partial date field aeDate (UNK-MMM-YYYY)
return FindMaxDateInRFs('aeDate', '01-JAN');
//to compare with another date
var maxd= FindMaxDateInRFs('a');
var today = new Date();
var maxdate = new Date(maxd);
if(dateDiffInDays(today,maxdate)>0){
return "today>max";
}
return "today<max";Parent topic: Repeating form functions