i want to know how to get Sobject in list.

pleas can any one help me.

thanks In Advance.

  • Parth, could you please detial your question or provide some context such as possibly the code you've already written? You can simply add sObjects to list like you can add primitive data types to lists. – Samuel De Rycke Jul 10 '15 at 14:36

May this example help you

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


 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;

You can use getGlobalDescribe() method in Schema namespace to get the list of sObjects.

List<string> SObjectList = new List<string>();
for(Schema.SObjectType objTyp : Schema.getGlobalDescribe().Values()){
    String name = objTyp.getDescribe().getName();
    // Exclude all the unwanted Sobjects e.g. History, Share etc..
    if(!name.containsignorecase('history') && !name.containsignorecase('tag') && !name.containsignorecase('share') && !name.containsignorecase('feed')){      

You can use this SObjectList. Schema namespace for your reference.

Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.