I have a requirement where I need to auto select few checkboxes on a checkbox fi

I have a requirement where I need to auto select few checkboxes on a checkbox field based on the selection done by user on the same checkbox field.
PFB example--
load(
local!result,
with(
a!formLayout(
firstColumnContents:{
a!checkboxField(
label:"Testing",

choiceLabels :{"All","Test1","Test2"},
choiceValues:{"All","Test1","Test2"},
value:if(rule!TipCheckIsNullV2(local!result),
{},
{local!result}),
saveInto:{local!result,
a!save(local!result,if(contains(result,"All"),{"All","Test1","Test2"},{local!result}))
},
required:true
),
a!textField(
value:local!result
)
}
)
)
)

I am using the above code to auto select both "Test1" and "Test2" if "All" is selected. Though the value is storing c...

OriginalPostID-220948

OriginalPostID-220948

  Discussion posts and replies are publicly visible

  • ...orrectly in local variable but the selection is not immediately reflecting on the UI right after selecting "All".
    Test1 and Test 2 are auto selecting once I click any where on the form after selecting "All".
    Can any one provide a work around solution for this. Thanks in advance
  • Hi, instead of load variable, take rule input (say ri!checkboxVals)and save ur values in the same, make this variable as multiple text .
    Before user input task ,in a script task save those values which u want to check default into Pv variable ( ex: save test1 n test2 into Pv! checkboxVals ).
    Pass this Pv to ri as input and ur requirement will be fulfilled
  • Hi jagannathh thanks for replying. I don't want Test1 and Test2 as default values they must be checked only if All is checked and there can be a scenario where only Test1 and Test2 can also be checked without selecting "All".
    Also I may come back to the same form later which should show the default values of previous selection. For this I am storing the data in Database
  • @bhanusreev Hi, I have already worked on a similar implementation some time ago and I don't think there is a clean solution unless an attribute similar to Paragraph Field's 'refreshAfter' is applied to CheckBox Field. I can confirm that same is the behavior experienced by me and it's expected.

    To the best of my knowledge, it's not about the usage of ri!, pv! or local! variables as said above. The behavior you are experiencing at the moment is due to the default behavior of the CheckBox Field SAIL Component. The problem with CheckBox Field SAIL Component here is, the component doesn't surface the latest(after being modified in saveInto) value (upon which the component is currently dependent in the 'value' attribute) until and unless we move out of the component.

    Anyway, I have come with a workaround and attaching the code snippet here. Please do testing and let us know how it works for you. The workaround I have made is, as we aren't in a position to refresh the value of the current component with which we are interacting, I am surfacing a different and a new component as the other components are able to reflect the updates.
  • @bhanusreev Please find the updated version of the above attached code snippet and I believe this would demonstrate much easily the way we switch between two different(but of same functionality) components.

    220948_modified.txt

  • Hi sikhivahans, thanks for replying. your code is working as expected,that was a good work around solution. Thanks for sharing. So do we face this issue only with Checkbox field? Thanks again.
  • @bhanusreev No problem, glad to hear that it helped you. I haven't explored much on this part, but I guess Radio Button SAIL Component also behaves in the same way.