one Product can have multiple Tags (field tags).
User can select multiple tags (saved on the User object, field selected_tags)
I want only to show the products which have one or more tag(s) among the user selected_tags. But given that the constraint start with the Product field I cannot use “contains”. Ideally I would write User's selected_tags contains one_of Product's tags.
I’m on my phone so can’t experiment for you. I think the expression below will only match if the product/item has all the categories a user entered. Can you check please because I can’t remember.
categories contains Do a Search For User (selected_categories)
I also can’t access the manual for many months but it depends on what country you are in. Most bubble users can. Try putting up another post asking someone for a screen grab of that section of the manual.
I can’t remember exactly how you get it but I know you put :filtered after the Search for Items:filtered and then the word Advanced appears and I think it is when you click on the word filtered as opposed to the Search for Items. In effect the Search for Items returns the full list from the server (fast) but the filter is applied in the client’s browser (slow) so if you have a long list it is best not to use this approach.
I know I’ve done something close to what you are talking about before without using advanced filters but I can’t remember exactly how. It was something to do with making the Data Source equals Search for X:merged with Search for Y. It might come to me but I’m offline now for a while.
I tried the formula “tags contains Do a Search For User (selected_tags)” but it stays red (I also tried adding “'s name” at the end). But anyway even if it worked, as I understand it it would show only the Products which contain all the User’s selected_tags. Whereas I want to show Products that have even one or more of the selected tags.
There are a few things I’m not sure about your data structures so what I have done is build a very simple app with three data tables Product, User and Tags. The Product and User both have a field that is a List of type=Tag (I presume you have this). And, the Tag’s data table has three fields, name, List of type=Product, of List of type=Users (not sure if you have this). The structure involves a little extra work because when a Tag is added/removed from a Product/User you must also update the Tags table. However sometimes when normalising data redundancy is the most efficient way to do what you need to do and this is one of those times.
My simple app works. If you check it out you will see that there are two users. If you run as one user you see all three Products. If you run as the other user you see only two products. Checking the few entries I put in the database you will see the answers are correct - I think they are what you are looking for.
The RG/List on the left is a list of the Current Users’s Tags - it should be a hidden RG of width 1, height 1 and have no element in the cells. Then your main RG, on the right in my sample, uses the hidden RG/Tags’s List of Products. I hope this helps.
That is the key ! I had one of those “hhhhhhhmmmm” moment when I read your paragraph. Will try this ASAP but this is the the logic. Thank you very much for the time taken to help
This is a bit tricky to update a Tag after a Product has been modified, because Tag can have been added but also removed.
The way I solve this which is probably not the most efficient, is first to go through all Tags and remove the Product (ex product_A) which has been modified in each. Then I go over all Tags that are assigned to this product_A and add it to their products list.
Note : there is actually no need to use a (hidden) repeating group as the source of the resulting Products repeating group, can get the data directly there