FindMinDateInRFs( )
Find the minimum value of given date, date-time, or partial date items in all repeating instances of the form identified by the form ID. This function is only applicable to date fields.
This is an aggregation function. The rule is run for each form instance in the case where the target is on a repeating form.
Syntax
FindMinDateInRFs('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/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
- Minimum date value in String format. For example,
'27-Jan-2021 00:00'
. null
if minimum 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-47 Get the minimum date value for an item across a set of repeating form instances
// Get the minimum date value for an item across a set of repeating form instances
return FindMinDateInRFs('aeDate');
// Same as above, using a partial date field aeDate (UNK-MMM-YYYY)
return FindMinDateInRFs('aeDate', '01-JAN');
//to compare with another date
var maxd= FindMinDateInRFs('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