findMaxIn2SForms( )
Find the maximum value of a given data item in all instances of a repeating section in a two-section form. This function works only for numeric fields.
For this function you can only use number-type questions. You cannot use drop-downs, radio buttons, or checkbox values as function parameters or as a target.
Note:
This is an aggregation function. The rule is run for each instance in the case where the target is on a repeating section of a two-section form.
Syntax
findMaxIn2SForms(formInstance,'variable')
Parameters
- formInstance
-
The form instance that gets searched to find the maximum value.
- If
formInstance
isnull
and variable is in flat section, the flat section of all instances is searched. - If
formInstance
isnull
and variable is in a table row, all table rows in all instances are searched. - If
formInstance
value is provided, the search is across the table rows of the specified instance only.
- If
- variable
-
Item variable to search, which reference path is:
eventId.formId.itemId
.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.
Return value
Returns the maximum value across all instances or
"0"
if no maximum can be found.
Example 3-64 Find the maximum value of "weight" number item across all repeating instances of a two-section form in a visit
// Given 5 repeating section instances in a two-section form with "weight" item containing values of "150, 200, 250, 300, 350"
return findMaxIn2SForms(null,'varWeight');
// returns 350
Parent topic: Two-section form functions