How do I grab elements from another list inside a "When FirebaseDB.GotValue" block?


This is the code for this screen.

For context, I have three lists stored in a FirebaseDB database, and all values that are related have the same position in the lists.(ex. 19.3.2020 is the date, -45 is the amount and Transport is the category, and on all three lists, their index is 4)
How would I go about setting the text of the listview to display the other two values which are positioned on the same index as the selected date? Or rather, how would I access these other two lists and their values with the same index as the date in its own list?

Any sort of help would be appreciated, and I will provide any further material if necessary.
Thank you!

2021.04.24-20.43_LI
As you can see here in the marked area is where one of the other lists is supposed to go but I do not understand how to access it because I could find no blocks that fit the use I need.

Unless the three lists are static lists, from which you are building a new set of data, it seems like too much of a rick to rely on the three lists remaining in sync.

It would make more sense to store your data in a tag with the three items - ["date","amount","category"]

1 Like

They aren't static but I made sure that all three values are inputted at the same time and on the same index, so that is not a problem for me right now. On the other hand, getting those values is what I am having trouble with.

Is it as simple as this ? (Textbox value = 2)

1 Like

I do not think you are understanding my problem here, I will try to explain it.
On this screen the user selects a date, that date is then stored in a variable(izabraniDatum). Based on that selected date, the app needs to fetch all the amounts and categories with the same index in their lists as that date in its respective list. What I am having trouble with is fetching those other two lists, but I think I am onto something.

Before I used to call GetValue for just one of the lists, now I am calling it for all three.
In the "When FirebaseDB.GotValue" block, I am checking which list got called and based on that I am choosing what to do next.

If it is the date list, I save all of the indexes of the dates that match the selected one in another list called index.
If it is the amount list, I go through the index list and for each element in that list I add the value that has the matching index as the number stored in the index list to yet another list.
If it is the category list, I do the same as with the amount list.

The problem now is that the block "select list item..." does not accept the FirebaseDB lists as actual lists for some reason.

Please show a screenshot of your firebase data (from the firebase console)

Another update...
I fixed it! :tada: :tada: :tada:
But now there is another issue. Because the selected dates are all identical (as they should be) it is only taking the index of the first one and repeating it for however many identical dates there are.

ex. If the signed in user (I will take manijak for this example) selected the 25th of April 2021, the app would only show the first iteration of that date and its related amount and category three times, because there are three different amounts and categories related to that same date three times.

Here is the new code:

You will need to use indexes ( for each number) instead of for each item blocks in order to overcome the calling of the first and subsequent entries, or as previously suggested transpose your firebase structure so that respective dates/amounts/categories are listed together.

1 Like

It worked!!!
Thank you so much for helping me, you have no idea how much I appreciate it!

Here is the code that works for the "GotValue" block:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.