Multiple Boolean Checkboxboxfield only one checkbox can be selected at a time

I need help with a concern. I have multiple record type fields that are boolean, and I need only one of them to have a value of true, while the rest should be null.

a!localVariables(
local!hearingSelected,
local!reminderSelected,
local!complianceSelected,


a!columnsLayout(
columns: {
a!columnLayout(
contents: {

a!checkboxField(
choiceLabels: {
"Hearing Required"
},
choiceValues: {
true
},
labelPosition: "COLLAPSED",
value: if(
ri!record['recordType!{8a8a403a-8fe2-4ed4-a3a3-9dd7b01f720d}SCA_IncidentTypev2.fields.{017a84f6-9869-4444-887a-3eddf23e1e97}hearingrequired'],
true,
null
),
saveInto: {
local!hearingSelected,
a!save(
ri!record['recordType!{8a8a403a-8fe2-4ed4-a3a3-9dd7b01f720d}SCA_IncidentTypev2.fields.{017a84f6-9869-4444-887a-3eddf23e1e97}hearingrequired'],
if(
isnull(
save!value
),
false,
true
)
)},
required: false,
choiceLayout: "COMPACT",
choiceStyle: "CARDS"
)
}
),
a!columnLayout(
contents: {
a!checkboxField(
choiceLabels: {
"Reminder Required"
},
choiceValues: {
true
},
labelPosition: "COLLAPSED",
value: if(
ri!record['recordType!{8a8a403a-8fe2-4ed4-a3a3-9dd7b01f720d}SCA_IncidentTypev2.fields.{edfd85a1-7524-4eeb-a1f3-a71da5e0f275}reminderrequired'],
true,
null
),
saveInto: {
local!reminderSelected,
a!save(
ri!record['recordType!{8a8a403a-8fe2-4ed4-a3a3-9dd7b01f720d}SCA_IncidentTypev2.fields.{edfd85a1-7524-4eeb-a1f3-a71da5e0f275}reminderrequired'],
if(
isnull(
save!value
),
false,
true
)
)},
required: false,
choiceLayout: "COMPACT",
choiceStyle: "CARDS"
)
}
),
a!columnLayout(
contents: {
a!checkboxField(
choiceLabels: {
"Compliance Required"
},
choiceValues: {
true
},
labelPosition: "COLLAPSED",
value: if(
ri!record['recordType!{8a8a403a-8fe2-4ed4-a3a3-9dd7b01f720d}SCA_IncidentTypev2.fields.{c058a7ed-fb86-46fd-9b9a-d8fe5de7f297}compliancerequired'],
true,
null
),
saveInto:
{
local!complianceSelected,
a!save(
ri!record['recordType!{8a8a403a-8fe2-4ed4-a3a3-9dd7b01f720d}SCA_IncidentTypev2.fields.{c058a7ed-fb86-46fd-9b9a-d8fe5de7f297}compliancerequired'],
if(
isnull(
save!value
),
false,
true
)
)},
required: false,
choiceLayout: "COMPACT",
choiceStyle: "CARDS"
)
}
)

}

)

)

  Discussion posts and replies are publicly visible

  • 0
    Certified Associate Developer

    Hi  

    When you are selecting one checkbox set other checkboxes as null in the selected value saveinto.

    When you are selecting Hearing Required set null as compliance and reminder, the same way you can implement for compliance and reminder as well.

    If the selected value is hearing - set null as compliance and reminder in hearing checkbox saveinto.

    If the selected value is reminder- set null as hearing and compliance in the reminder checkbox saveinto.

    If the selected value is compliance- set null as hearing and reminder in the complaince checkbox saveinto

    eg:

    In hearing checkbox saveinto

    {

    a!save(

    local!reminderSelected, null()

    ),

    a!save(

    local!complianceSelected, null()

    )

    }

  • +1
    Certified Associate Developer

     

    a!localVariables(
      local!hearingSelected,
      local!reminderSelected,
      local!complianceSelected,
      a!columnsLayout(
        columns: {
          a!columnLayout(
            contents: {
              a!checkboxField(
                choiceLabels: { "Hearing Required" },
                choiceValues: { true },
                labelPosition: "COLLAPSED",
                value: local!hearingSelected,
                saveInto: {
                  local!hearingSelected,
                  a!save(
                    {
                      local!complianceSelected,
                      local!reminderSelected
                    },
                    null()
                  )
                },
                required: false,
                choiceLayout: "COMPACT",
                choiceStyle: "CARDS"
              )
            }
          ),
          a!columnLayout(
            contents: {
              a!checkboxField(
                choiceLabels: { "Reminder Required" },
                choiceValues: { true },
                labelPosition: "COLLAPSED",
                value: local!reminderSelected,
                saveInto: {
                  local!reminderSelected,
                  a!save(
                    {
                      local!complianceSelected,
                      local!hearingSelected
                    },
                    null()
                  )
                },
                required: false,
                choiceLayout: "COMPACT",
                choiceStyle: "CARDS"
              )
            }
          ),
          a!columnLayout(
            contents: {
              a!checkboxField(
                choiceLabels: { "Compliance Required" },
                choiceValues: { true },
                labelPosition: "COLLAPSED",
                value: local!complianceSelected,
                saveInto: {
                  local!complianceSelected,
                  a!save(
                    {
                      local!hearingSelected,
                      local!reminderSelected
                    },
                    null()
                  )
                },
                required: false,
                choiceLayout: "COMPACT",
                choiceStyle: "CARDS"
              )
            }
          )
        }
      )
    )

    Try this!

  • 0
    Certified Lead Developer

    Did you consider to use radio buttons? This is exactly what they are made for. From a UX perspective, building singular check boxes is misleading.

  • 0
    Appian Employee
    in reply to Stefan Helzle

    Yeah completely agree with Stefan - it will be easier to configure as a radio button, and your users are more likely to understand it correctly when it uses that pattern.