+ Start a Discussion

Reg: Picklist & custom objects. (VFCODE)



I have 10 custom objects.


I would like to retrieve all my custom objects into a picklist using Apex code...



Please suggest me.




Thanks & Regards:






kruti tandelkruti tandel



if you want to fetch all the Object into the picklist. here code is given



<apex:pageblocksection >

         <apex:selectList value="{!selectedObject}" size="1" id="selobj"  >

            <apex:selectOptions value="{!objectNames}"/>



//*********** controller********//

public class AllObjectFetch{

        private Map <String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
        public List <SelectOption> objectNames {get;set;}
        public String selectedObject {get; set;}
	   public AllObjectFetch() {

	   objectNames = initObjNames();


  private List<SelectOption> initObjNames(){
        List<SelectOption> objNames =  new List<SelectOption>();
        List<String> AllFields = new List<String>(schemaMap.keySet());
        for(String name : AllFields)
            objNames.add(new SelectOption(name,name));
        return objNames;