Salesforce Certified Application Architect

Tuesday 6 May 2014

How to remove duplicates from list in Salesforce?

Create a map instead of list and finally if you want to insert or update the map values then you can insert or update.


Sample Code:

Map<Id, Account> mapAccount = new Map<Id, Account>();

for(Account acc : listAccount){
...............
...............
mapAccount.put(acc.Id, acc);
}

update mapAccount.values();


Note: Update Map value instead of List..


Cheers...

No comments:

Post a Comment

Salesforce Certified Application Architect & Certified Data Architecture and Management Designer Exam

How to pass Salesforce Certified Data Architecture and Management Designer Exam This exam was 1st architect exam for me. Its not that muc...