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

Parents
  • @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.
Reply
  • @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.
Children
No Data