Hi there
Currently, I load an API into a repeating group. In this RG I also added a checkbox with the condition, when the date from this API-call exists in a specific bubble db, mark it as checked.
Now I would like to save only these records into the database, where the checkbox is checked finally. Because the users can manipulate the preselected checkboxes.
In the pictures: the records that should be stored into the db are
Lets say your RG holds Things. Add a custom state on the repeating group. This custom state is a list of Things.
Populate this custom state with your initial data, and make a workflow on the toggle button to add or remove the current’s row Thing to or from the custom state list.
You might need to re-create a toggle button and not use the bubble one.
When you need to save, save the custom state list of Things.
Could you make an example when the list of things are coming from an API-call and the toggle switcher are not set in the API-call (they switch on when the one condition is true). Maybe I get a glimpse who it should be done on my side.
The date and the name in the repeating group are coming from an API. The toggle switcher switches by a condition (if the current row record is in the database).
Now I would like to click on a save-button and it saves all the records from the repeating group where the toggle switch is on. If it is easier to do, a checkbox would also be good.
(Side note: because there is no boolean value in the API-call, I cannot get this value from the repeating group list of things.)
If the API Call is coming in as JSON I highly recommend the plugin JSON Assistant by @NoCodeDataArtisan
You could use this plugin to manipulate the JSON response, and effectively add a key of type bolean value with a trigger based on the condition. Then you could simply refer to the API data and filter by Yes/No = Yes, for example.
As @bonjour_17 advised, the fewer plugins, the better. To have a list of Things with checked checkboxes to save, store them in a custom state (type = API call response type).
If your toggle switch/checkbox (which appears to be a custom one) allows you to trigger the workflow through which you can add/remove the current cell Thing from the custom state, then you have everything needed to create such a list of Things that can be saved.
If your checkbox doesn’t allow this, then you can:
Add an input (1px x 1px) to the RG cell
Add the condition “when checkbox checked, initial content is 1; if not, 0” to it
Add two workflows to the page type Elements > An input value changed:
One should fire when the custom state contains the current cell Thing and remove it from the custom state
The second should fire when the custom state doesn’t contain the current cell Thing and add it to the custom state
Then you can save this custom state list of Things into the DB.
I made it by adding the current cells’record of the API instead of trying to match two datasets (API and the toggle switcher.)
But how can I set the custom state list on page load with all the records where the toggle switch (or checkbox) is yes? I would like to prefill the custom state with the checkboxes = yes on page load.
In these example, only the two rows should be set into the custom state