getAnswerVariable()

The getAnswerVariable() function (client-side) retrieves the value of the custom variable associated with the answer.

Syntax

Use this syntax for the getAnswerVariable() function:

            getAnswerVariable('QUESTION_CODE/ANSWER_CODE', 'CustomVariableName'); 

          

Return Value

The getAnswerVariable() function returns the value of the custom variable as a string.

            'Custom Variable Value' 

          

Parameters

Note:

All parameters are required.

The getAnswerVariable() function accepts the following parameters:

  • QUESTION_CODE/ANSWER_CODE (string) - Specifies he combination of question and answer codes that identifies the answer. You can find the codes in the Code field on the respective records.

  • CustomVariableName (string) - Specifies the name of the custom variable associated with the answer. You can find custom variables under the Custom Variables subtab on the answer record.

Example

The following examples show how to use the getAnswerVariable() function.

Retrieving the Custom Variable Value

This example retrieves the value of the "Color" custom variable for the "Lamp" answer in the "Select accessories" question. The value assigned to "Color" is "Blue".

              const customVariableValue = getAnswerVariable('ACCESSORIES/LAMP', 'Color');
console.log(customVariableValue); 

            

The returned value for the custom variable will be:

              Blue 

            

Related Topics

General Notices