Removing Duplicates in a Repeating Group's Data Source

I am currently facing an issue with a repeating group where I need to display a list of sub food items. The list should be a combination of two types of sub food items:

  1. Sub food items that have already been added to the user’s basket (which include quantities).
  2. Sub food items available to add to the basket (which have not been chosen yet, and would typically have a default quantity like 0).

The challenge arises when there are duplicates across these two lists – if a sub food item with a specific name exists in both lists, I want to display only the version that is in the basket (with its associated quantity) and exclude the unchosen version.

My current setup merges these two lists, but I am struggling to apply a filter that removes the unchosen items without affecting the display of items that need to be shown (i.e., items with a quantity greater than 0 that are already in the basket).

Is there a way to conditionally merge lists and filter out duplicates based on item names while prioritizing items that are in the basket?

Any suggestions or alternative methods to approach this problem would be greatly appreciated.

What is a sub food item??

All you need is a Line Item data type with Food Item and Quantity. Store a List of Line Items on the User data type for a Shopping Cart.

For the basket:

Current User's Line Item's

For the rest of the items:
Do a search for Food Items where (unique ID isn't in Current User's Line Item's:each item's Food Item's:unique ID)
or
Do a search for Food Items:minus list Current User's Line Item's:each item's Food Item

This topic was automatically closed after 70 days. New replies are no longer allowed.