Skip to main content
code formated to remove scroll bar
Source Link
Chirag Mehta
  • 1.3k
  • 1
  • 12
  • 29

Though not 100% an answer, but based on various posts and comments (like one from @Andrew), below is a solution which will give you a list of all standard and custom objects ignoring system objects:

public List<SelectOption> getStandardCustomIgnoreSytemObjects() {

  List<SelectOption> options = new List<SelectOption>();
  for (Schema.SObjectType item1: Schema.getGlobalDescribe().values())
  {
    String name = item1.getDescribe().getName();
    // Exclude all the unwanted Sobjects e.g. CustomSettings, 
    // History, Share, Feed, ApexClass, Pages etc..
    if (!item1.getDescribe().isCustomSetting() 
        && item1.getDescribe().getRecordTypeInfos().size() > 0 
        && item1.getDescribe().isCreateable() 
        && !name.containsignorecase('history') 
        && !name.containsignorecase('tag') 
        && !name.containsignorecase('share') 
        && !name.containsignorecase('feed')) {
         options.add(new SelectOption(item1.getDescribe().getName(),
                                      item1.getDescribe().getLabel()));
        }
  }
  options.add(new SelectOption('Asset', 'Asset')); 
  // Asset doesn't come- up, so explicitly add the same.
  options.sort();
}

Though not 100% an answer, but based on various posts and comments (like one from @Andrew), below is solution which will give you list of all standard and custom objects ignoring system objects:

public List<SelectOption> getStandardCustomIgnoreSytemObjects() {

  List<SelectOption> options = new List<SelectOption>();
  for (Schema.SObjectType item1: Schema.getGlobalDescribe().values())
  {
    String name = item1.getDescribe().getName();
    // Exclude all the unwanted Sobjects e.g. CustomSettings, 
    // History, Share, Feed, ApexClass, Pages etc..
    if (!item1.getDescribe().isCustomSetting() 
        && item1.getDescribe().getRecordTypeInfos().size() > 0 
        && item1.getDescribe().isCreateable() 
        && !name.containsignorecase('history') 
        && !name.containsignorecase('tag') 
        && !name.containsignorecase('share') 
        && !name.containsignorecase('feed')) {
         options.add(new SelectOption(item1.getDescribe().getName(),
                                      item1.getDescribe().getLabel()));
        }
  }
  options.add(new SelectOption('Asset', 'Asset')); 
  // Asset doesn't come-up, so explicitly add same.
  options.sort();
}

Though not 100% an answer, but based on various posts and comments (like one from @Andrew), below is a solution which will give you a list of all standard and custom objects ignoring system objects:

public List<SelectOption> getStandardCustomIgnoreSytemObjects() {

  List<SelectOption> options = new List<SelectOption>();
  for (Schema.SObjectType item1: Schema.getGlobalDescribe().values())
  {
    String name = item1.getDescribe().getName();
    // Exclude all the unwanted Sobjects e.g. CustomSettings, 
    // History, Share, Feed, ApexClass, Pages etc.
    if (!item1.getDescribe().isCustomSetting() 
        && item1.getDescribe().getRecordTypeInfos().size() > 0 
        && item1.getDescribe().isCreateable() 
        && !name.containsignorecase('history') 
        && !name.containsignorecase('tag') 
        && !name.containsignorecase('share') 
        && !name.containsignorecase('feed')) {
         options.add(new SelectOption(item1.getDescribe().getName(),
                                      item1.getDescribe().getLabel()));
        }
  }
  options.add(new SelectOption('Asset', 'Asset')); 
  // Asset doesn't come up, so explicitly add the same.
  options.sort();
}
public List < SelectOption > getStandardCustomIgnoreSytemObjects() {
    List < SelectOption > options = new List < SelectOption > ();
    for (Schema.SObjectType item1: Schema.getGlobalDescribe().values()) {
        String name = item1.getDescribe().getName();
        // Exclude all the unwanted Sobjects e.g. CustomSettings, History, Share, Feed, ApexClass, Pages etc..
        if (!item1.getDescribe().isCustomSetting() && item1.getDescribe().getRecordTypeInfos().size() > 0 && item1.getDescribe().isCreateable() &&
            !name.containsignorecase('history') && !name.containsignorecase('tag') && !name.containsignorecase('share') && !name.containsignorecase('feed')) {
            options.add(new SelectOption(item1.getDescribe().getName(), item1.getDescribe().getLabel()));
        }
    }
    options.add(new SelectOption('Asset', 'Asset')); // Asset doesn't come-up, so explicitly add same.
    options.sort();
}
public List<SelectOption> getStandardCustomIgnoreSytemObjects() {

  List<SelectOption> options = new List<SelectOption>();
  for (Schema.SObjectType item1: Schema.getGlobalDescribe().values())
  {
    String name = item1.getDescribe().getName();
    // Exclude all the unwanted Sobjects e.g. CustomSettings, 
    // History, Share, Feed, ApexClass, Pages etc..
    if (!item1.getDescribe().isCustomSetting() 
        && item1.getDescribe().getRecordTypeInfos().size() > 0 
        && item1.getDescribe().isCreateable() 
        && !name.containsignorecase('history') 
        && !name.containsignorecase('tag') 
        && !name.containsignorecase('share') 
        && !name.containsignorecase('feed')) {
         options.add(new SelectOption(item1.getDescribe().getName(),
                                      item1.getDescribe().getLabel()));
        }
  }
  options.add(new SelectOption('Asset', 'Asset')); 
  // Asset doesn't come-up, so explicitly add same.
  options.sort();
}
public List < SelectOption > getStandardCustomIgnoreSytemObjects() {
    List < SelectOption > options = new List < SelectOption > ();
    for (Schema.SObjectType item1: Schema.getGlobalDescribe().values()) {
        String name = item1.getDescribe().getName();
        // Exclude all the unwanted Sobjects e.g. CustomSettings, History, Share, Feed, ApexClass, Pages etc..
        if (!item1.getDescribe().isCustomSetting() && item1.getDescribe().getRecordTypeInfos().size() > 0 && item1.getDescribe().isCreateable() &&
            !name.containsignorecase('history') && !name.containsignorecase('tag') && !name.containsignorecase('share') && !name.containsignorecase('feed')) {
            options.add(new SelectOption(item1.getDescribe().getName(), item1.getDescribe().getLabel()));
        }
    }
    options.add(new SelectOption('Asset', 'Asset')); // Asset doesn't come-up, so explicitly add same.
    options.sort();
}
public List<SelectOption> getStandardCustomIgnoreSytemObjects() {

  List<SelectOption> options = new List<SelectOption>();
  for (Schema.SObjectType item1: Schema.getGlobalDescribe().values())
  {
    String name = item1.getDescribe().getName();
    // Exclude all the unwanted Sobjects e.g. CustomSettings, 
    // History, Share, Feed, ApexClass, Pages etc..
    if (!item1.getDescribe().isCustomSetting() 
        && item1.getDescribe().getRecordTypeInfos().size() > 0 
        && item1.getDescribe().isCreateable() 
        && !name.containsignorecase('history') 
        && !name.containsignorecase('tag') 
        && !name.containsignorecase('share') 
        && !name.containsignorecase('feed')) {
         options.add(new SelectOption(item1.getDescribe().getName(),
                                      item1.getDescribe().getLabel()));
        }
  }
  options.add(new SelectOption('Asset', 'Asset')); 
  // Asset doesn't come-up, so explicitly add same.
  options.sort();
}
Source Link
Chirag Mehta
  • 1.3k
  • 1
  • 12
  • 29

Though not 100% an answer, but based on various posts and comments (like one from @Andrew), below is solution which will give you list of all standard and custom objects ignoring system objects:

public List < SelectOption > getStandardCustomIgnoreSytemObjects() {
    List < SelectOption > options = new List < SelectOption > ();
    for (Schema.SObjectType item1: Schema.getGlobalDescribe().values()) {
        String name = item1.getDescribe().getName();
        // Exclude all the unwanted Sobjects e.g. CustomSettings, History, Share, Feed, ApexClass, Pages etc..
        if (!item1.getDescribe().isCustomSetting() && item1.getDescribe().getRecordTypeInfos().size() > 0 && item1.getDescribe().isCreateable() &&
            !name.containsignorecase('history') && !name.containsignorecase('tag') && !name.containsignorecase('share') && !name.containsignorecase('feed')) {
            options.add(new SelectOption(item1.getDescribe().getName(), item1.getDescribe().getLabel()));
        }
    }
    options.add(new SelectOption('Asset', 'Asset')); // Asset doesn't come-up, so explicitly add same.
    options.sort();
}