function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Remove duplicate values from a List



I Need to remove duplicate values from a list .I used the following code but still the values in the list are not removed and I get the original list itself.


--here Catalogue is my Object


Set<SITEdu__Catalog__c>  CaAg = New Set<SITEdu__Catalog__c>();
List<SITEdu__Catalog__c> CaAgListresult = new List<SITEdu__Catalog__c>();
List<SITEdu__Catalog__c> CaAgList = new List<SITEdu__Catalog__c>();
public List<SITEdu__Catalog__c> getStudentAgView()
    CaAgList = [select SITEdu__CatalogType__c from SITEdu__Catalog__c];  
    return CaAgListresult;



Could someone please guide me in getting this done.


Thanks in Advance,




Val ValinoVal Valino

With the way you are currently doing it, each record is different for the Catalog even though they have the same Catalog Type. 


why not use of set or map?


Oh...So will set remove the duplicates with the same name from the object. Cant that be used to remove duplicates from a list.?

Kindly guide me.


Yeah I have tried using set for that..I have mentioned how I have used it in the message.Kindly let me know if that is not the right way of doing .I still get the duplicates in the list by doing so.


Thank you so much,