Hi, can anyone help me? How do I get all this “tarefas” information that’s in the userID and list it in a list?
What are you trying to determine? If you check for divisibility by 1, isn’t that going to work for any numeric value? Are you trying to determine if a Firebase value is a number or text? Or something else?
What happens if you display the variable j as a label’s text and add a Wait block right after that so you can watch the values from Firebase change during the for loop? Are the values what you expected? If so, those values are text strings, not numbers. So you might need to convert the depending on what you’re trying to determine.
I’ve tried it so too, and it really works it shows all the “tarefas” of the user, but in case when some user doesn’t have any “tarefas” in firebase it gives an error… The error says that there is some wrong block.
The result is like this, the list showing all the “tarefas” that are in the user’s userID(users), but when there is no task in the “tarefas” in the user’s userID it ends up giving an error that I don’t know how to resolve, I had added that division account because I was looking at another topic here in the community, but now that you said it I removed it but another error occurs, before with the division account it worked almost 100%, the problem is that all the division tasks did not appear. “tarefas” only appeared one. The error that appears when there is no division account and there is no tarefas in the user’s userID is that there is a wrong block.
The best way to fix that is to make sure every user has the “tarefas” property, even if it’s empty. But if you can’t do that, try this…
Project link: Thunkable (see the first screen)
The code below loops through the users and tries to get the “tarefas” property. If it can’t, it replaces the value with an empty string (“”). That way there is no error. To change the get property of object
block to the one in the screenshot, right-click on the block and choose Show advanced block.
I used this JSON (scroll down or copy it to see the full JSON):
{
"usuarios": {
"IGC1PAvIczT4I8xDogLHZBljCUB2": {
"tarefas": [
"ffu",
"ffu7w7w",
"ffu7w7wuid",
"dhh"
]
},
"NewUserID12345AbCdEfGhIjK": {
"proyectos": []
},
"UsrID67890ZxYvUtSrQpLmN": {
"tarefas": [
"task1",
"task2",
"task3"
]
},
"AnotherUsrID54321MnOpQrSt": {
"tarefas": [
"itemA",
"itemB",
"itemC"
]
}
}
}
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.