Skip to main content

Value Types for SET_RESPONSES command

Summary

The SET_RESPONSES command is an object used by Question Code Automation functions to return specified values and insert them to answer the indicated survey question.

SET_RESPONSES must return values in the data type or format of the survey question's content type.

Micro-Tutorial

In this micro-tutorial, we made a survey form that automatically selects options in a multiple-choice question. We can pre-select options by returning a SET_RESPONSES command and indicating the target and values.



You can add further logic to set the answers with variables and predefined contexts.

For example, you can use variables to call other predefined survey values:

variable example

The code displayed above will give the following result:

variable example

Command Field Descriptions

Sample:

{
cmd: 'SET_RESPONSES`,
target: 'question_01',
value: '5'
}
FieldDescriptionValues
cmdIndicates the command type.SET_RESPONSES
targetIndicates survey question where the value will be placed.'self' | 'Identifier of the survey question'
valueThe value to be placed in the target field.The value must correspond to the question's content type. Value type examples are shown below.

Value Types

Text

Description: Used for text components.
Content Type Code: application/vnd.cotalker.survey+text
Notes: Any characters in string format.

Example:

{
cmd: 'SET_RESPONSES',
target: 'question_05',
value: 'Hello world!'
}

Text Input

Description: Used on a written answer component.
Content Type Code: application/vnd.cotalker.survey+textinput
Notes: Any characters in string format.

Example:

{
cmd: 'SET_RESPONSES',
target: 'question_02',
value: 'Hello world!'
}

Text Number

Description: Used on rating components for evaluating with a number-star system.
Content Type Code: application/vnd.cotalker.survey+textnumber
Notes: Number in string format. The number must be within the rating range that was set up.

Example:

{
cmd: 'SET_RESPONSES',
target: 'question_01',
value: '5'
}

List Question

Description: Used on multiple choice component item list type. Choose items from a list made during survey setup.
Content Type Code: application/vnd.cotalker.survey+listquestion
Notes: The value is an array of strings, where the strings are the "values" indicated in the component setup.

Example:

{
cmd: 'SET_RESPONSES',
target: 'self',
value: ['b', 'c']
}

Property

Description: Used on multiple-choice component collection types when the elements of the indicated collection are given as options.
Content Type Code: application/vnd.cotalker.survey+property
Notes: Use an ObjectId<COTProperty> array, i.e., the _id of the elements (properties) to return as values.

Example:

{
cmd: 'SET_RESPONSES',
target: 'question_03',
value: ['6185cfe1ef46d0aee4c2b653', '6185cfe8b420610501b280d8']
}