Hi @Anonymous ,
To retain the state of checkboxes between sessions in PowerApps, you can use the "OnVisible" property of the screen to load the previously selected checkboxes from your collection when the app opens. Additionally, you can use the "OnChange" property of each checkbox to update the collection as the user selects or deselects them.
Here's a step-by-step guide on how to achieve this:
Add the "OnVisible" property to your screen:
Go to the screen properties, find the "OnVisible" property, and set it to the following formula:
ClearCollect(CollSelected, Filter(yourDataSource, trueCheckboxColumn = true))
Replace "yourDataSource" with the name of your data source, and "trueCheckboxColumn" with the column name that determines if the checkbox should be selected (true) or not (false).
Set the "Items" and "OnChange" properties for each checkbox:
For each checkbox control, set the "Items" property to your data source (e.g., "yourDataSource") and the "OnChange" property to the following formula:
If(ThisItem.Selected, Collect(CollSelected, ThisItem), Remove(CollSelected, ThisItem))
Add a button to save the selection (optional):
If you want to give the users control over when to save their selections, you can add a "Save" button. Set the "OnSelect" property of the button to the following formula:
Patch(yourDataSource, CollSelected)
That's it! Now when the app opens, the "OnVisible" formula will load the previously selected checkboxes into the "CollSelected" collection, and the "OnChange" formula for each checkbox will update the collection as the user makes selections. If you added a "Save" button, users can choose to save their selections back to your data source whenever they want.