SObjectType Example

SObjectType Example: How to Retrieving the list of Salesforce objects from the Org?

SObjectType Example: Here is the example to get all Salesforce objects in a picklist values from any Salesforce org.

Visualforce page:

<apex:page sidebar="false" controller="DObjDisplay">
<apex:form > 
<apex:selectlist multiselect="false" size="1">
<apex:selectOptions value="{!objNames}">

Apex Class:

public with sharing class DObjDisplay {
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.

Here the visualforce page o/p preview:

SObjectType Example


One thought on “SObjectType Example”

Leave a Reply