get2SValues( )

Retrieve values for the provided variables of a two-section form or variables of a table in a two-section form based on the tableInstance parameter.

If you want to fetch a single value from a two-section form instance, consider getQuestionValue( ).

Syntax

get2SValues(formInstance, tableRowInstance, ['var1', 'var2', 'varN'])

Parameters

formInstance

Instance number of the two-section form to retrieve values from. This can be a JavaScript variable or a number.

tableRowInstance

Instance number of the table of the two-section form to retrieve values from. This parameter is null if you want to retrieve the value from the flat part of the two-section form. This parameter can be a JavaScript variable or 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 same name as passed in param2) with values:

  • The returned variable value is the C1Date object if the variable is a partial date, or a Date object if the variable is a full date. You can check this using the isPartialDate( ) function.
  • If the variable is a choice control (checkbox, radio, or drop-down), the returned variable value is in JSON format: ("[{\"value\":\"3\",\"label\":\"TestLabel\"}]"). This can be parsed using JSON.parse or the helper function parseChoice( ).

    • parseChoice(rfData.v4_chk4))
    • JSON.parse(rfData.v4_chk4))
  • The return object has a property named exists which returns true if any one of the variables passed in has value for the passed in two-section form instance number.

Example 3-78 Get values for three item variables in AE form instance #1, and put them to a text item

// Get values for 3 item variables in AE form instance #1, and put them to a text item
var rfData = get2SValues(1, null, ['aeTerm','aeDate','aeSerious'] );
if(rfData.exists){
   return rfData.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
var rfData = get2SValues(1, 2, ['aeTerm','aeDate'] );
if(rfData.exists && rfData.aeTerm && rfData.aeDate){
   return rfData.aeTerm + "  | "  + rfData.aeDate.getFullYear() ;
} else {
    return;
}