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.
(We have discontinued our premium membership offering. If you are an existing premium member, you can still download the guides by clicking on “DOWNLOAD PDF [PREMIUM MEMBERS]” button. If you are not a premium member and want to download the guides, please sign up for our “All Access” pass. Complete details about this pass is available at this URL.)
References & Useful URLs
- Tooling API Objects – Salesforce Developers Documentation (15 mins) – https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/reference_objects_list.htm
- Salesforce Object Query Language – Salesforce Developers Documentation (15 mins) – https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/api/sforce_api_calls_soql.htm#!
11 thoughts on “How to Query/Report on Metadata in Your Salesforce Org”
How to retrieve “Error Condition Formula” of an validation rule?
Hi Sree, looks like ErorrConditionFormula field is not supported in the SOQL Query.
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?
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
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 ?
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.
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.
I found this blog post very useful. Especially the last part where you can copy the results to Excel. Thanks!!
Thanks Kavita, glad to note that you found this useful.
Very very useful.
Thanks, Nachiket 🙂