+ Start a Discussion
steven75steven75 

Picklist values from standard object

Hi,

 

Basically, I want to created a picklist that lists of all SalesForce users (standard object User) in the New Opportunity form.   I went to Setup/Customize/Opportunities/Fields, and clicked New to created a new custom field name "UserList".  However, there is no option for me to select a User standard object as list values. 

 

Is there a way I can do this in Apex code or VisualForce?   I am new to this, if possible, please give me the steps.

 

Thanks,

Pradeep_NavatarPradeep_Navatar

Tryout the sample code given below :

 

             public List<SelectOption> getUserList()

                                     {

             List<SelectOption> optionList = new List<SelectOption>();

             optionList.add(new SelectOption('','- None -'));     

 

             For (User u : [select name,id from User order by Name])

                                                 {

                optionList.add(new SelectOption(u.id,u.name));

             }

              return optionList;    

             }

 

            For more information go through the following documentation :

 

            http://wiki.developerforce.com/index.php/Extended_Functionality_of_Visualforce_-_Part_2

 

Hope this helps.

steven75steven75

I will try it out, thank you.