[SalesForce] Querying for all Standard and Custom Objects

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.

Best Answer

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()
    );
Related Topic