List viewer repeating the list items each time screen is opened

Hi,
I was trying to display a list in list viewer by using Firebase DB. Unfortunately, if I open the screen in which that list viewer is in(Read Recommendations), it duplicates the same values each time I open the screen.
I tried clearing the list viewer before adding the list items, but no luck there!
Here is the code:


Please note that the value in variable ‘Book_List’ are being saved in another variable called ‘Books_List’.
I have also attached the screenshot of the code in the screen where I enter the list items as well below:

I had read all the other community discussions similar to this but there is a slight difference: Since this is an app which can be accessed by every user, there are scenarios where the user will be giving the same values as another user had given. I do not want to clear these values. I only want to clear the values which the bug in my code has duplicated.
Thanks in Advance,
Vikhyath

1 Like

Reset the list not the list viewer.

You need to reset Book_List to empty list.

Do this
image

instead of resetting the list_viewer

1 Like

Hi Sir,
I tried what you said, but now nothing displays in list viewer because the variable is empty when it is displayed in list viewer since I set it to empty list.

This is the way I have changed the code as per your suggestion:

1 Like

This is wrong
image

You should use the green block value instead of app variable Book_List. This is assuming that the result of the Get Block is actually a list.

1 Like

If you are sure the result of the Get Block is a list then all what you need is this

image

1 Like

Hi Sir,
Firstly, thank you for your quick replies.

The green block value is not actually a list. It is an object containing properties:
image

And it is not displaying anything in list viewer

What could I do?

1 Like

The image of your Firebase means you tried to save a List into the DB directly
image

Firebase does not actually know how to deal with simple list and therefore it saves it and adds internal identifiers to refer to it in the correct way.

I advise you delete this entry and start fresh the appropriate way. Refer to Thunkable documentations to see how to save lists to the database.

1 Like