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
Suresh RaghuramSuresh Raghuram 

Avoid adding duplicate values into picklist

Hi Community,

Below is the sample code
List<User> salesOffice = [Select id, Sales_Office__c, profile.Name from User  where Sales_Office__c != null];

for(User usr: salesOffice){

this.pickList.add(new salesOffice(usr.Sales_Office__c, usr.Sales_Office__c));

}
From the above process I am getting the duplicate values in the picklist and displaying in the alphabetical order. 

Any Ideas please.

Thanks,
Suresh.

kk
Hi Suresh,

Do u have duplicate values in Sales_Office__C field?
If yes then loop through the salesOffice list and put it into a set<String>.
Suresh RaghuramSuresh Raghuram
Ya I did it with a set but made a mistake by placing it under another for loop now i corrected my mistake thanks for the reply