Skip to main content
Hi how can i remove duplicate from list of object ! i try like this but it's doesn't work 

 

public static List<State__c> getState(){

List <State__c> first = [SELECT Id,Name,Child__r.Name FROM State__c];

List<State__c> uniqueValue = new List<State__c>();

Set<State__c> myset = new Set<State__c>();

for (State__cs : first) {

if (myset.add(s)) {

uniqueValue.add(s);

}

}

return uniqueValue;

}

my list is like this :

 

suucces[{"Id":"a0b5E000002VSuXQAW","Name":"Abbes","Child__c":"a0Z5E000002s12BUAQ","Child__c":{"Name":"Abbes","Id":"a0Z5E000002s12BUAQ"},"Public__c":true},{"Id":"a0b5E000002VSajQAG","Name":"Abbes","Child__c":"a0Z5E000002s12BUAQ","Child__r":{"Name":"Abbes","Id":"a0Z5E000002s12BUAQ"},"Public__c":true}]

2 réponses
  1. 24 avr., 09:54

    Tried this but it didn't work ?

0/9000