I built a checkbox list based on a collection from Xano. Now I would like to create a variable with an array that lists the names of all the ticked checkboxes.
I was able to make this work with a different element through the currentSelection. However with my checkbox from Xano I am not given a currentSelection that I can use to define my variable.
Please watch this brief screen recording to explain my issue.
Hi Mariano, I thought I could replicate your tutorial for the exact same use case, just with a different item from the same collection.
Here is a quick video to better explain my issue:
The only difference that I think could have not made this work is that all the specialisation names are unique, whereas the risk group numbers are duplicate at times with the same items in the collection having the same risk group. Nonetheless, they should still be correctly linked to each of my checkboxes.
You need to use unique ids for this to work, it can’t work with duplicated ids because you can’t know which one you need. Once you have a list of selected ids you can get all the other data from your collection.
Initially I thought your suggestion worked using unique ids. The performance initially was fine, but I only realised now that when I start clicking the checkboxes very quickly the array eventually becomes inaccurate. This is still not the case for my initial use case where the ids are much “more unique”
It is indeed a method that suffer from race conditions, but it’s the easiest and quickest implementation.
There are various methods to overcome that, like inserting every change in a queue where operate the same logic, or storing the data in a different way (an object like {id1:{checked: true}, id1:{checked: false}}).
I just made a wild set of selections but slowly in between clicks and found no errors. I heavily suspect this to be a performance on WeWeb, although then I still don’t understand why it’s not the case for longer id strings (or more unique as previously defined)
I can work around this with a time delay workflow, but this does not seem like a great solution?
Makes sense, but then how come I am not having the race condition issues in my other array that is set up the exact same way. They are on top of each other in my workflow could this be part of the problem?
instead of an array store the checkob status in an object like {id1:true, id2:false} where the keys are the ids and the values are boolean for the checkbox status.
Regarding my interim solution of using a time delay, I am only able to implement this within my “on change” workflow. But not on the actual ability to “change” the checkbox statues and trigger the whole workflow. Any ideas how to implement a time delay for my purpose?
a time delay will only create delayed race conditions.
Not sure why you have two updates because once you know the id of what is selected you can access the rest of the data.