+ Start a Discussion

Unique (or No Duplicate) Results from a Related List

I am using apex:repeat to display a related list, but I'd like to only display unique results. How do I achieve this?


Just for some frame of reference - It's a list of a custom object (OBJ) that is related to my Quote Line Items, so multiple Quote Line Items may be related to the same OBJ - I want to list out all the OBJs referenced in the Line Items without it displaying duplicates if its related to more than one line item.

Best Answer chosen by Admin (Salesforce Developers) 
Change your controller so that it runs the following query: [select id,Name... from Obj__c where id in (select object__c from QuoteLineItem where Quote.Opportunity.Id = :oppid)] Where oppid is an ID to the opportunity, object__c is the lookup on your QuoteLineItem to the custom object, and Obj__c is your object's name. This should return a unique list of Obj__c that you can display in your repeat tag.