Skip to main content
Known Participant
Apr 9, 2025 7:04 PM UTC
Question

Checkbox field error

I've been trying to implement a checkbox field but keep receiving an error. I can select either choice. I can select nothing. But if I select both choices, I get the following error: 

Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function a!checkboxField [line 638]: A checkbox component [label=""] has an invalid value for "value". All selected values must be present in the choiceValues array, but value was Fatality; Serious Injury and choiceValues was Fatality; Serious Injury.

For reference, this is the code I am using:

What am I doing wrong? 

4 replies

Participating Frequently
Apr 10, 2025 2:30 AM UTC

Hi [mention:eb99822c11d540d59fbe9b9c56d4165b:e9ed411860ed4f2ba0265705b8793d05] 

The issue is because you are trying to save multiple values in a single field. If you want to select multiple values the value must be a type of array.

a!localVariables(
  local!data:{},
  a!checkboxField(
    label:"Skills",
    choiceLabels: {"C","C++",".net","java","appian"},
    choiceValues: {"C","C++",".net","java","appian"},
    value: local!data,
    saveInto: local!data
  )
)

stefanhelzle0001
Brainy
Apr 10, 2025 5:36 AM UTC

Storing multiple values in one field is a dangerous design decision. If this is what you want/need, you can use something like this:

a!localVariables(
  local!boxValue,
  a!checkboxField(
    choiceLabels: {"Option 1", "Option 2"},
    choiceValues: {1, 2}, /* Integers here */
    label: "Checkboxes",
    labelPosition: "ABOVE",
    saveInto: a!save(
      target: local!boxValue,
      value: joinarray(a!defaultValue(save!value, {}), ";")
    ),
    value: if(
      a!isNullOrEmpty(local!boxValue),
      null,
      tointeger(split(local!boxValue, ";")) /* Integers here */
    ),
    validations: {}
  )
)

An alternative is, to store the values in JSON format using toJson() and fromJson().

New Participant
May 5, 2025 6:39 AM UTC

Check if the value matches exactly with the choiceValues array options.

arulk0002
Inspiring
May 5, 2025 7:19 AM UTC

 [mention:eb99822c11d540d59fbe9b9c56d4165b:e9ed411860ed4f2ba0265705b8793d05] 

It seems that your record text type does not support multiple selections when using checkbox. To store multiple selected values, consider using a local variable, a rule with the 'AnyType' data type, or a map function