getRFValues( )
Retrieves the current values for specified items on repeating form instances.
Syntax
This is an aggregation function, the rule will be run for each form instance in case the target is on a repeating form.
If you'd like to fetch only a single value from a repeating form instance, you may also consider getQuestionValue( ).
getRFValues(formInstance, ['var1', 'var2', 'varN'] )
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 |
Required | The instance number of the form you're retrieving values from. This parameter can be a JavaScript variable or it can be a number. |
isNullConsidered |
Optional | Item variable names, passed in using single quotes, for the values to retrieve. |
Return value
Returns a JSON object containing the variables (of the same name as passed in the second parameter) 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.
Examples
Example 3-61 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