Need checkboxField to deselect options when certain options are selected.

I have an ask to make a checkbox field have the following logic. 

Checkbox has four items. If option ITEM 1 is selected then selection of ITEM 2, ITEM 3, ITEM 4 should be deselected automatically.

If options ITEM 2, ITEM 3, ITEM 4 are selected then option ITEM 1 should be deselected automatically.

Below code tracks the current values for the checkbox field in local!setA, previous values in local!setB, and the difference between the two sets which indicates what object the user just clicked in local!setDIFF.

The issue we are encountering is that when the deselection logic is triggered, I can see local!setA's value meets the requirement but the checkboxField UI doesn't. It still shows the options as selected when they have been removed from local!setA. User has to make another mouse click action like clicking around the page then the UI reflects the local!setA values.

Has anyone experienced a similar issue with checkboxField and were able to have the checkbox options refresh to match the local value?

a!localVariables(
  local!setA:null,
  local!setB:null,
  local!setDIFF:null,
  a!checkboxField(
    align:"LEFT",
    labelPosition:"COLLAPSED",
    choiceLayout:"COMPACT",
    choiceLabels:{"ITEM 1","ITEM 2","ITEM 3","ITEM 4"},
    choiceValues:{"ITEM 1","ITEM 2","ITEM 3","ITEM 4"},
    value: local!setA,
    saveInto: {
      a!save(local!setB,local!setA),
      a!save(local!setDIFF,difference(save!value,local!setB)),
      a!save(local!setA,
      if(
        contains(local!setDIFF,"ITEM 1"),
        {"ITEM 1"},
        difference(save!value,{"ITEM 1"}),
      )
      )
    }
  )
)

  Discussion posts and replies are publicly visible

Parents
  • I'm curious about your use case - is the goal here to have item 1 show as "Select All" and also allow them to choose individual items? If that's the case, I'd probably suggest a different design pattern entirely to meet your goal. For instance, you could create a link that says "Select All" which would then save all of the selections at once. Then, if any item is deselected, you don't need to update any other checkboxes.

Reply
  • I'm curious about your use case - is the goal here to have item 1 show as "Select All" and also allow them to choose individual items? If that's the case, I'd probably suggest a different design pattern entirely to meet your goal. For instance, you could create a link that says "Select All" which would then save all of the selections at once. Then, if any item is deselected, you don't need to update any other checkboxes.

Children