I am trying to do a search for all original products by name in a repeating group. No duplicate items.
If I do a search for: Products :each item’s name :unique elements in a textbox, I get myself a list of original items. But if I do the same expression in a repeating group, it doesn’t work and the expression goes red.
What am I doing wrong please? This should be so simple but I cannot find a suitable answer anywhere. Thanks In Advance!
That is because in the repeating group it is likely set to data type of Products and not text, and since you are referencing what is likely a text field (ie: each item’s name) it would result in an improper dynamic expression.
Instead you should just do a search for Products followed by the :unique elements operator
But then I get a list of products with duplicate names as they are not unique elements if they have different values in their other fields such as quantity. I just want the first items of each name?
Does your use case allow you to prevent users creating duplicates in the first place?
Or, if you want them to create duplicates, why can’t you just display products with different names (e.g Amazon/eBay will let you have the same name as another product and that’s no problem at all)
If you share more about the use case then people here will happily point you in the best direction for your app
Well I have found a work-around now, where I simply filter out products without an empty quantity field and make sure any products added to cart have a quantity. However, I was hoping to be able to select just the first of each item by name as I had done in a textbox and wish to be a more proficient bubbler (is that a term?). It just seems such a common use case for products.
I should have just made a separate data type for products and products added to cart in the first place but my solution should be sufficient.
You should have a Product data type, and a Line Item data type. Line Item contains a Product and a quantity (number field). A shopping cart is made up of a list of Line Items.
Yeah thanks for that, unfortunately the youtube tutorial I was following was a bit simplistic and it’s gonna be a lot of work to reimplement now, so I will stick with the solution I have got and heed your advice in future apps. Thanks anyway!