Need checkbox to remain selected if set

I have this checkbox when checked sets the priority on the case. Currently the value is defaulted to 0. When its set the value updates from 0 to 100 and I should be able to check the value and if its 100 when the end user returns they will see the box is checked and can uncheck it to reset the case value back to 0.

Currently I have the functionality of setting/saving the value updating the case all working with a process model. Even when they return they can check the box again and it will set the value back to 0. But I cannot figure out how to keep the box checked like the screenshot when the end user returns. It’s always unchecked.

local!choices: if(local!case.priorityRank > 0, 0, 100),
local!updatePriorityRank: null,
 
a!sectionLayout(
      label: "",
      contents: {
        a!sectionLayout(
          label: "Case Priority",
          contents: {
        a!checkboxField(
          label: "",
          choiceLabels: {"Priority"},
          choiceValues: {local!choices},
         
          value: local!updatePriorityRank,
          saveInto: local!updatePriorityRank,
          choiceStyle: "STANDARD"
        )
    }
)

  Discussion posts and replies are publicly visible

Parents Reply
  • +1
    Certified Lead Developer
    in reply to seenaomi

    So the first problem you're facing here is, the checkbox field doesn't work as straight-forwardly as what you're attempting.  This is understandable, it's not the easiest thing to understand especially when you're trying to use it as a boolean (and really it's not meant to be used that way, though it *can*).

    The checkbox field always assumes a LIST of items will be provided, and a LIST of values (down to an empty list) will be the VALUE.

    In your case, you're passing a hardcoded list of a single label (Priority) accompanied by a semi-hardcoded list of a single value (choices, so either 0 or 100).  But your saveInto is not making any accounting for what you're actually trying to accomplish - that is, switching between 0 or 100.  You'll need to do a bit more bending over backwards first.

    The second problem here is, your local variable (the aforementioned value and save target) is not making any reference to the current value of local!case upon form load.  So as I mentioned before, it will always load blank.  The way the checkbox field works, when you pass in a blank value as the value of the list of the checkboxValues list (regardless of what the valid values list contains), it'll populate the checkbox as empty.

    Stand by and I'll try to whip up a code snippet with things rearranged in such a way that they work more as you're expecting here, and you might see what I mean.

Children
No Data