Filter duplicates from a dropdown menu

Hello,

I have a dropdown menu reading from users “current city”. If multiple users live in the same city, a dropdown of that column will result in duplicates. How can I remove that?

Is there a way to remove/hide duplicates?

I’m not sure I understand how you set this up in your DB.

My recommendation would be to have a collection of Cities and a relation to users. Then you can have a drop down of the cities and there won’t be duplicates and you can filter throughout your app accordingly.

3 Likes

This is great if its a fixed collection (i.e. user has no option to add an entry) otherwise it will add an extra step for each selection (i.e. select from list, if not there then add, then select from updated list).

My workaround for now is to create an extra true/false property called “duplicate?” and update it during the creation with true if it exists in the list. Then in the drop down filter duplicate = false.

2 Likes

That isn’t necessary. You can have all of the actions on the same button - create new city, add user to city, take user to next screen

2 Likes

Thanks Erik for your detailed reply.