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.
- 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#!