Here is the example to get all Salesforce objects in a picklist values from Salesforce org.
Visualforce page:
<apex:page sidebar="false" controller="ObjDisplay">
<apex:form >
ObjectName:
<apex:selectlist multiselect="false" size="1">
<apex:selectOptions value="{!objNames}">
</apex:selectOptions>
</apex:selectlist>
</apex:form>
</apex:page>
Controller:
public with sharing class ObjDisplay {
Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();
public List<SelectOption> getobjNames(){
List<Schema.SObjectType> gd = Schema.getGlobalDescribe().Values();
List<SelectOption> options = new List<SelectOption>();
for(Schema.SObjectType f : gd){
options.add(new SelectOption(f.getDescribe().getName(),f.getDescribe().getName()));
}
return options;
}
}
Schema class Contains methods for obtaining schema describe information.
No comments:
Post a Comment