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
Animesh DattaAnimesh Datta 

Duplicate id in set to list conversion


In order remove duplicate records, I converted List to Set and converted same set to list. But, converted list still is giving duplicate records. Please assist.
List<Property__c> propertyList = new List<Property__c>();
	Set<Property__c> propertySet = new Set<Property__c>();
	//propertySet //unique
	for(Property__c prop : propertySet){		
		system.debug('propertyList++++++'+propertyList) //duplicate records
		Database.update(propertyList,false);//duplicate id in list

Santosh Jayakar DiyyalaSantosh Jayakar Diyyala
You are iterating the set and adding to the list.  :)
try this
01    for(Property__c prop : propertyList){       
02               propertySet.add(prop);
03      }
Animesh DattaAnimesh Datta
But again i need a list as i am passing the same in database.update
Santosh Jayakar DiyyalaSantosh Jayakar Diyyala
it's simple convert the set to List..:)
Amit Chaudhary 8Amit Chaudhary 8
Please post your full code where you are pulling propertySet set So that we can help you