getRFValues( )
Retrieves the current values for specified items on repeating form instances.
Syntax
If you'd like to fetch only a single value from a repeating form instance, you may also consider getQuestionValue( ).
Note:
This is an aggregation function, the rule will be run for each form instance in case the target is on a repeating form.
getRFValues(formInstance, ['var1', 'var2', 'varN'] )
Parameters
- formInstance
-
The instance number of the form you're retrieving values from. This parameter can be a JavaScript variable or it can be a number.
- var1, var2, varN
-
Item variable values to retrieve.
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 a JSON object containing the variables (of the same name as was passed in param2) with values:
- Returned variable value will be a C1Date object in case of variable being a partial date, or variable value will be a Date object in the case of the variable being a full date. This can be checked using the isPartialDate( ) function as illustrated below.
- If the variable is a choice control (checkbox, radio button, or drop-down) then the returned variable will be in JSON format: (
"[{\"value":\"3\",\"label\":\"TestLabel\"}]"
). This can be parsed usingJSON.parse
or parseChoice( ).parseChoice(rfData.v4_chk4))
JSON.parse(rfDate.v4_chk4))
- The return object has a property name
'exists'
which returns true if any one of the variable passed in has a value for the passed in repeat form instance number.
Example 3-59 Get values for 3 item variables in AE form instance #1, and put them to a text item
varrfData = getRFValues(1, ['aeTerm','aeDate','aeSerious'] );
if(rfData.exists){
returnrfData.aeTerm + " | " + rfData.aeDate.getFullYear() + " | "+ JSON.parse(rfData.aeSerious)[0].label;
} else{
return;
}
// It is best practice to check if the variable has value before using it
varrfData = getRFValues(1, ["aeTerm","aeDate"] );
if(rfData.exists && rfData.aeTerm && rfData.aeDate){
returnrfData.aeTerm + " | " + rfData.aeDate.getFullYear() ;
} else{
return;
}
Parent topic: Repeating form functions