How to have the document ID (reference) of an option selection from a dropdown list based on a Firebase collection

How to return/save the reference/ID or another field of an option selection from a dropdown list based on a Firebase collection

Assume there is a Users collection of three documents:

Peter
Kim
Peter

Assume the three documents of the Users collection looks like this:

Users collection:
document ID, userName, userEmail
id0001, Peter, [email protected]
id0002, Kim, [email protected]
id0003, Peter, [email protected]

I can create a droplown list where it shows the three user names by first doing "Add Backend Query". Then a selection will be stored in the "DropDown" variable (string) under Widget State category.

But I would like to have the document ID because document ID is the unique one to identify records (documents). So a person is using the app and selected a field value and the app system should know its corresponding ID (reference).

If user names are unique, I can make a 2nd backend query in which I can add a filter that the DropDown value == userName field of User collection. As a beginner, first of all, I'm not sure if it's the standard way. I think it's not efficient as it queries the whole collection again.

Thanks a lot!!

2
5 replies