+ Start a Discussion
TarentTarent 

Retrieve a List of Objects using Apex

Retrieve a List of Objects using Apex?

Navatar_DbSupNavatar_DbSup

Hi,

Try the below code as reference:

 

<apex:page controller="objectList" >
<apex:form >
<apex:SelectList value="{!val}" size="1">
<apex:selectOptions value="{!Name}"></apex:selectOptions>
</apex:SelectList>
</apex:form>
</apex:page>

////////////////////////////////////// Controller ///////////////////////////////////////////////////////////

public class objectList{
public String val {get;set;}

public List<SelectOption> getName()
{
List<Schema.SObjectType> gd = Schema.getGlobalDescribe().Values();
List<SelectOption> options = new List<SelectOption>();

for(Schema.SObjectType f : gd)
{
options.add(new SelectOption(f.getDescribe().getLabel(),f.getDescribe().getLabel()));
}
return options;
}
}

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.