getMatching2SFormsCount( )
Get the number of repeating instances in a two-section form that match the item values provided as search keys.
Syntax
- Can accept choice controls (radio controls, check box controls, and dropdowns) but can only be searched by label, not value.
- Only one option can be provided as search text for choice controls.
- Dates must be provided inside the string
'Date(dd-mmm-yyyy hh:mm:ss)'
. - You can use partial dates in the following formats:
- <dd-mmm-yyyy hh:mm>
- <dd-mmm-yyyy hh>
- <dd-mmm-yyyy>
- <mmm-yyyy>
- <yyyy>
- Times must be provided inside the string
'Time(hh:mm:ss)'
. - You can use partial times in the following formats:
- <hh:mm>
- <hh>
getMatching2SFormsCount(formInstance, 'variable1', value1, 'variable2', value2, ...)
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 |
---|---|---|
formInstance |
Optional | Determines within which two-section form instance or
section to look for a duplicate:
|
variable |
Required | Rule variable to evaluate, passed in using single quotes. |
value |
Required | Value to search for. |
Return value
Number that represents the count of matching instances depending on the
passed in parameters:
- If
formInstance
isnull
and variable is in flat section, the count of matching repeating form instances will be returned. - If
formInstance
isnull
and variable is in a table row, the count of matching repeating table row instances will be returned. - If
formInstance
value is provided and variable is in the flat section, the count of matching instances within the flat section of specified form instance will be returned. - If
formInstance
value is provided and variable is in the table section, the count of matching repeating table row instances within the specified form instance will be returned.
Note:
In dates,UNK
values are considered to match any other
value. For example: 'Date(01-Feb-2022)'
and
'Date(20-Feb-2022)'
are both considered as a match of an
entry with UNK-Feb-2022
date value.
Examples
Example 3-78 Raise a query if there is more than one instance where AE Outcome is "Fatal"
// Raise a query if there is more than one instance where AE Outcome = 'Fatal"
// Get current repeating instance
var ins = GetCurrent2SFormInstance();
var curVal = "";
// Get value of aeOut from current instance
var 2sData = get2SValues(ins,getCurrent2STableInstance(),['aeOut'] );
if(2sData.exists && 2sData.aeOut){
if((2sData.aeOut) !== "[]"){ // If the choice control has been cleared out then do not read the label
curVal = JSON.parse(2sData.aeOut)[0].label;
}
}
// check to see if there are more than 1 instance with "Yes"
return ((curVal == "Fatal") && (getMatching2SFormsCount(1, 'aeOut', '[{"value":"3","label":"Fatal"}]') > 1))?false:true;
Parent topic: Two-section form functions