Skip to main content
Known Participant
Dec 4, 2023 12:07 PM UTC
Question

Issue with Radio button Field

Hii,

I am unable to select NA option , for YES or NO Its  working fine , how can i resolve this, 

i have to save

 a!radioButtonField(
                  label: "",
                  choiceLabels: { "Yes", "No", "N/A" },
                  choiceValues: { 1, 0, "NA" },
                  value: fv!item['recordType!{f42d5bd8-9c50-4910-b251-13ec6bf9fdb6}GAI App Review.fields.{899275d5-d9e3-4030-9291-883eaf45d2c6}reviewerAnswerBool'],
                  saveInto: {
                    local!a,
                    a!save(
                      fv!item['recordType!{f42d5bd8-9c50-4910-b251-13ec6bf9fdb6}GAI App Review.fields.{899275d5-d9e3-4030-9291-883eaf45d2c6}reviewerAnswerBool'],
                      if(local!a = "NA", {}, local!a)
                    )
                  },
this value in to boolean type column

6 replies

davidj137213
Brainy
Dec 4, 2023 12:20 PM UTC

"NA" (choiceValues) is not a boolean value, check setting this value to 1 (for example, only for testing purporses)

Known Participant
Dec 4, 2023 12:28 PM UTC

but duplicate value is not allowed in choice value it is giving error

stefanhelzle0001
Brainy
Dec 4, 2023 12:56 PM UTC

You cannot store three different values in a boolean. Switch to a text or number type.

mikes0011
Brainy
Dec 4, 2023 4:31 PM UTC

technically a boolean can handle yes, no, or null - OP is just doing this incorrectly.

The Expression Guru
mikes0011
Brainy
Dec 4, 2023 4:58 PM UTC

Your main issue here is that you also need to do some trickery in the "value" field to make it work.  Without some more advanced trickery, you will need to settle on the radio button starting off with a default selection of "N/A" when the user has not yet made any selection.  Otherwise an approach like the following should be very easy:

a!localVariables(
  local!booleanValue: toboolean(null()),
  
  a!radioButtonField(
    label: "3-way boolean selector",
    choiceLabels: {
      "Yes",
      "No",
      "Null Value"
    },
    choiceValues: {
      true(),
      false(),
      "null"
    },
    value: if(
      a!isNullOrEmpty(local!booleanValue),
      "null",
      local!booleanValue
    ),
    saveInto: {
      a!save(
        local!booleanValue,
        if(
          save!value = "null",
          null(),
          save!value
        )
      )
    }
  )
)

The Expression Guru