Skip to main content
December 4, 2023
Question

Issue with Radio button Field

  • December 4, 2023
  • 6 replies
  • 0 views

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
December 4, 2023

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

December 4, 2023

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

stefanhelzle0001
Brainy
December 4, 2023

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

mikes0011
Brainy
December 4, 2023

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

The Expression Guru
mikes0011
Brainy
December 4, 2023

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