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
sowjanya bheemasowjanya bheema 

hello all,how to write soql on account object and how to create a picklist to display account name as label and phone as avalue

Durga PaavanDurga Paavan
Could you give more details Please?
Sunil RathoreSunil Rathore
Hi,
Please use the following code: 
<!-- VF Page------------>
<apex:page controller="AccountCustomController ">
    <apex:form >
    <apex:selectList size="1" value="{!selectedname}"> 
        <apex:selectOptions value="{!selectedaccnamefields}"/>  
    </apex:selectList>
    </apex:form>
</apex:page>

/***** Controller Class**********/
public class AccountCustomController {
    Public string selectedname{get;set;}
        Public List<Selectoption> getselectedaccnamefields(){
            List<Selectoption> lstnamesel = new List<selectoption>();
            lstnamesel.add(new selectOption('', '- None -'));
            for(Account acc :[SELECT id,name,phone,type,industry FROM Account]){
            lstnamesel.add(new selectoption(acc.phone,acc.name));
            }
            return lstnamesel; 
        }
}
Let me know if it helps you.

Many Thanks,
Sunil Rathore
sowjanya bheemasowjanya bheema
thanks a lot its works
Sunil RathoreSunil Rathore
Hi Sowjanya,

If it solves your problem then please mark it the best answer so that it may help others who are facing the same problem and can be found easily.

Many Thanks,
Sunil Rathore