setChoiceValue( )

Use this helper function in a calculated rule to add a value to an existing choice (drop-down, radio button, or checkbox).

The expression creates a string JSON value that must be returned to the target control and must be used in combination with [Deprecated] - clearChoice( ).

If you want to set the label instead of the value see setChoiceLabel( ).

This rule helper function is approved for use in Screen Candidate rule execution.

Syntax

setChoiceValue(valueStr, variable)

Parameters

Parameter Required or Optional Description
labelStr Required String value you want to set for the given choice type field.
variable Required Rule variable, corresponding to a choice type field, that you want to set.

Return value

This function returns a JSON object with the string array of the labels of the selected choice options. If no values are selected it returns an empty object.

Examples

Example 3-89 Given a drop-down (choice) control with multiple labels including "Allergies" and "Obesity" with values "4" and "45" respectively, as the target of the calculation rule

// Select label "Allergies" having value "4"
if (someCondition) {
    return setChoiceValue("4");
} else {
    return clearChoice();
}
// selects "Allergies" in the calculated control
   
// Select "Allergies" having value "4" and "Obesity" having value "32"
var b;
if (someCondition) {
    b = setChoiceValue("4");
    return setChoiceValue("32", b);
} else {
    return clearChoice();
}
// selects "Allergies" and "Obesity" in the calculated control