2

Is there a way to get a list of all Standard and Custom Objects in an organization through SOQL or other means?

I'm trying to create a table list to show all Standard and Custom Objects as a flexible way for an admin to choose what to show a particular user in a Lightning Component.

1

1 Answer 1

5

You surely can using Schema.getGlobalDescribe(), as mentioned in the comments. It returns a Map<String, SObjectType>, so you can get a Set<String> objectNames or a List<SObjectType> quite easily from it, among other uses. For instance, you could easily use it to generate a List<SelectOption> for use in a classic Visualforce Page:

List<SelectOption> objects = new List<SelectOption>();
for (SObjectType sObjectType : Schema.getGlobalDescribe().values())
    objects.add(new SelectOption(
        String.valueOf(sObjectType),
        sObjectType.getDescribe().getLabel()
    );
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .