setChoiceLabel( )

Use this helper function in a calculated rule to add a selection 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 value instead of the label see setChoiceValue( ).

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

Syntax

setChoiceLabel(labelStr, variable)

Parameters

Parameter Required or Optional Description
labelStr Required String value of the label 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-88 Given a drop-down (choice) control with multiple labels including "Allergies" and "Obesity" as the target of the calculation rule

// Select "Allergies"
if (someCondition) {
    return setChoiceLabel("Allergies");
} else {
    return clearChoice();
}
// selects "Allergies" in the calculated control
   
// Select "Allergies" and "Obesity"
var b;
if (someCondition) {
    b = setChoiceLabel("Allergies");
    return setChoiceLabel("Obesity", b);
} else {
    return clearChoice();
}
// selects "Allergies" and "Obesity" in the calculated control