Hi Friends,
There is a requirement to retrieve a list of objects in an organization to process them.
Here is the solution:
There is a requirement to retrieve a list of objects in an organization to process them.
Here is the solution:
VisualForce Page to create list of Objects in a picklist:
<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 for Above code:
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;
}
}
Thanks....
Is this code correct? where did you call getName()??
ReplyDelete