Problem repeating item in list viewer

It’s not impossible, but it can lead to unexpected results in certain circumstances. The basic issue is that 'LocalStorage.Get' (and Set) is currently an asynchronous operation, meaning that it is executed more-or-less at the same time as the blocks that come after it - including blocks that come after it in a loop. That’s we we have the 'then do' slots, which tell the 'LocalStorage.Get' what to do once it gets a result.

This affects your loop in that all the 'Users.Get' blocks will execute at more or less the same time. Moreover, they will all happen at more or less the same time as your loop is incrementing the 'Friends' variable! So the value of 'Friends' with the 'Users.Get' blocks could be just about any value between 1-25 in any of the 'Users.Get' blocks.

I wrote a little more about this sort of problem in Asynchronous Blocks within Loops. It also contains a workaround for how to deal with such issues.

Also note that we are thinking about possible solutions to this issue, but have no timetable yet.

I’ll also just note that @User81 is correct that you need test for the string “null” rather than the using the green null-block. I know it’s confusing ;-( . He’s also right that it would be easier if you could just save and get the entire list at once. Then you can loop over the list and have fewer problems.

-Mark

2 Likes