I’m trying to store the current values from a data source into a list and then randomly display it. After being displayed, if the button is pressed again the row is removed from the list. I had great success using this same approach for random numbers, but when I try to use the data source I cant get the values. I have also checked and tried old posts like this, but removing the data would also impact the data source.
Here is my work right now, any help would be greatly appreciated!
Hi and welcome to Thunkable!
What you posted looks like the right approach for getting a random data source value and then removing it from the data source. I’m not sure why that wouldn’t work. What happens if you try to get a specific item from the list? For example, “get #3” instead of “get and remove random”? Does that work?
Ah, okay, I think I know what’s happening here. I had to run a test of those blocks myself to figure it out. When you get and remove a random item from the
list of values block, it does get a random value but it’s essentially attempting to remove a value from a temporary list storage. You can’t modify data source values that way. The
list of values block holds the values from the data source but it isn’t actually the data source. Confusing?
So to do this properly requires a different approach. A simple fix is to assign the
list of values block to an app or stored variable and then when you use the
get and remove block on that variable, it will modify the list because it’s held in a variable.
If you need to also update the data source itself (not just the copy of the data held in the variable), you’ll need a few other blocks.
It worked perfectly thank you!
You’re welcome! You can mark my post as a solution by clicking the checkbox at the bottom.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.