setAnswer()
The setAnswer() function (client-side and server-side) sets a specific answer for a question.
If you use this function in asynchronous code, call scopeRefresh(), scopeApply() or renderView() to apply the changes.
Syntax
Use this syntax for the setAnswer() function:
setAnswer('QUESTION_CODE', 'ANSWER_CODE');
Return Value
The setAnswer() function returns undefined.
Parameters
All parameters are required.
The setAnswer() function accepts the following parameters:
-
QUESTION_CODE(string) - Specifies the code of the question for which to set the answer. You can find the code in the Code field on the question record. -
ANSWER_CODE(string) - Specifies the code of the answer for which to retrieve the value. You can find the code in the Code field on the answer record.
Examples
The following examples show how to use the setAnswer() function.
Setting a Specific Answer
This example assigns the answer with the code A1000 to the question with code DESK_MODEL.
setAnswer('DESK_MODEL', 'A1000');
scopeRefresh();