How to Query/Report on Metadata in Your Salesforce Org

An Easier Way to Find Out about Metadata in Your Salesforce Org

As a Salesforce Admin or Consultant, you may want to find out about the metadata in your Salesforce Org from time to time. For example, how many custom objects are there, what are the fields in the custom objects, how many triggers are there in your org, how many of those are inactive, how many apex classes are there, how many of those are from managed packages and so on.

The most common way to find these things out will be logon to your Salesforce Org, navigate to setup, go to each of the sections individually  and then gather the information. But this is a labor-intensive,  manual and time-consuming exercise. There is a better way…

Rather than sifting through all the different options in your setup menu, you can use simple English to get the information you want in no time. And we are going to do this using Developer Console, Tooling API and SOQL query. Now before you freak out and start thinking this is not for you, stay with me and let me show you how easy this is going to be.

We are going to write a query in simple English to retrieve the information. This simple query in English known as SOQL (stands for Salesforce Object Query Language). We will be writing and executing this query in the Developer Console. So Developer Console becomes our UI or User Interface. And this query will be executed using the Tooling API and will retrieve the results of the query. This happens behind the scene so you don’t really need to worry about this. With these three things in your arsenal, there is absolutely no need to manually scan the entire Salesforce org and you have just saved yourself quite a lot of time and effort. 🙂

So, here is a step-by-step guide on how to query/report on metadata in Salesforce and believe this can be helpful and beneficial for everyone, especially Salesforce Admins and Consultants who deal with metadata all the time. 

  • Create a Simple SOQL Query
  • Create a Complex SOQL Query
  • Export Query Results to Excel
  • Review Available Tooling API Objects

It won’t take you more than 10-15 minutes to understand how this works so let’s dive right in. 

NOTE: Certain sections of the guide will appear as locked in the free preview. You can download the unlocked version of the guide in PDF format by subscribing to our “All Access” Pass through the link below.

Not an “All Access” Pass Member Yet?

Get Download Access to this & 150+ More Step-by-Step Guides with “All Access” Pass. A simple and single plan to access our entire library of courses, guides, workshops & masterclasses on Salesforce.

References & Useful URLs

11 thoughts on “How to Query/Report on Metadata in Your Salesforce Org”

  1. Engouday Makonnen

    Thank you Anish,

    I found your blog on Salesforce org Metadata query using Entity Definition and Field Definition through Custom Report Type and SOQL inside Developer Console super helpful. Thank you

    I was able to query for just custom object by filtering QualifiedAPIName like ‘__c’ but I wanted to get a list of all the custom object for particular Custom Application.

    How can I query for CustomApplication , I was not able to see the CustomApplication, CustomObject and CustomField inside my dev console under new resources but I looked at the available Tooling API Objects list and CusomApplication , Custom Object and CutomField available

    Is it possible to query for example for custom object group by application so I get able to identify objects associated to the particular application?

    1. Ashish Agarwal

      Hi Engouday, in Developer Console, under ‘Query Editor’ tab, there is a checkbox that says, ‘Use Tooling API’. Please check that box and then run the SOQL query “select label from customapplication” and it will show you the result. I have tried it in my Salesforce org and it works. These objects won’t show under Resources, but the query will work once you have checked the ‘Use Tooling API’ box.

      Hope this helps. Cheers, Ashish

  2. Debkumar Mukherjee

    Hello Ashish
    This is a very good blogpost . I have a uqery if you can assist me with . When I navigate to Open resource and search for the validationrule or CustomField object , it is showing me those objects. When I try to run the query using any of these 2 objects , it returned me an error like this “select Active from ValidationRule
    ^
    ERROR at Row:1:Column:20
    sObject type ‘ValidationRule’ is not supported. If you are attempting to use a custom object, be sure to append the ‘__c’ after the entity name. Please reference your WSDL or the describe call for the appropriate names.”

    is there anything that I am missing here ?

  3. Great articles and slides!! do you know how to query Profile metadata object? I don’t know how to access to the Metadata field/value(is an array object /object), to see more things about profile metadata info.

    1. Thanks Guillermo. To query an array object you will need a little bit of Apex coding. I don’t have the code myself, but should be able to find some useful examples on the Internet.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top