Persist list of checkbox selections on records with related children
Hi,
I'm having difficulty finding the best approach to updating a list of checkbox options on a parent record using related record associations. Essentially, I am exploring the ability to save multiple selections (child rows) on the "create" of a new record and ability to "update" those persisted selections through an update process. I have a simple example expressed below through the use of local variables for clarity but hoping a few insights will help me understand how to apply at a recordType level with related record data. The content related to post# 22489 was very helpful but not fully understanding how we can add new items and also remove (inactivate the unselected items). The end result would be the use of a checkbox or multipledropdown field where a user can add new rows (isActive: true()) by selecting and unselect saved rows (set isActive: false()) to write back to the record table.
Sample code:
a!localVariables(
local!supplyList: {
{ id: 1, item: "Pencil" },
{ id: 2, item: "Paper" },
{ id: 3, item: "Binder" },
},
local!student: {
id: 1,
name: "John Smith",
suppliesNeeded: {},
},
local!selections,
{
a!checkboxField(
label: "Choose Supplies",
choiceLabels: index(local!supplyList, "item", null),
choiceValues: index(local!supplyList, "id", null),
value: local!selections,
saveInto: {
local!selections,
a!save(
target: local!student.suppliesNeeded,
value: a!forEach(
items: local!selections,
expression: {
id: fv!item,
isActive: true()
}
)
)
}
)
}
)
Screenshot of example in work:

Any insight would be gladly appreciated!
