I have created an apex class which is returning the wrapper List of account Name and phone number. You can use this wrapper list any where as you want.
public class PickListCreation {
public static List<AccountNameVSPhone> createPicklistMethod(){
List<AccountNameVSPhone> AccountNameVSPhoneList = new List<AccountNameVSPhone>();
try{
List<Account> accountList = new List<Account>();
accountList = [SELECT Id,
Name,
Phone
FROM Account
LIMIT 50000];
if(accountList.size() > 0){
for(Account accobj : accountList){
AccountNameVSPhone obj = new AccountNameVSPhone();
obj.Lavel = accobj.Name;
obj.Value = accobj.Phone;
AccountNameVSPhoneList.add(obj);
}
}
System.debug('AccountNameVSPhoneList-->'+AccountNameVSPhoneList);
if(AccountNameVSPhoneList.size() > 0){
return AccountNameVSPhoneList;
}
}catch(Exception e){
System.debug('Exception :'+e.getMessage()+' AT Line : '+e.getLineNumber());
}
return null;
}
public class AccountNameVSPhone{
public String Lavel;
public String Value;
}
}
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Greetings to you!
I have created an apex class which is returning the wrapper List of account Name and phone number. You can use this wrapper list any where as you want.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha