Understand Dependencies Between Metadata Components in Your Org Using the MetadataComponentDependency Object in Bulk API 2.0 (Beta)

Use new Tooling API endpoints in Bulk API 2.0 to query the dependency relationships between metadata components in your Salesforce org. Understanding relationships helps you in different ways, such as finding unused custom fields and evaluating dependency relationships before making edits. Using these endpoints to query the MetadataComponentDependency object, you can retrieve up to 100,000 records in a single query.

Where: This feature is currently available only in sandboxes. To use Bulk API 2.0, the API Enabled permission must be enabled.

Note

Note

As a beta feature, querying the MetadataComponentDependency Tooling API object using Bulk API 2.0 is a preview and not part of the “Services” under your master subscription agreement with Salesforce. Use this feature at your sole discretion, and make your purchase decisions only on the basis of generally available products and features. Salesforce doesn’t guarantee general availability of this feature within any particular time frame or at all, and we can discontinue it at any time. This feature is for evaluation purposes only, not for production use. It’s offered as is and isn’t supported. Salesforce has no liability for any harm or damage arising out of or in connection with it. All restrictions, Salesforce reservation of rights, obligations concerning the Services, and terms for related Non-Salesforce Applications and Content apply equally to your use of this feature. You can provide feedback and suggestions for MetadataComponentDependency in the Dependency API / Field Usage (Beta) group in the Trailblazer Community.

Why: Salesforce orgs can get messy due to unchecked growth of inefficient customization and integrations, resulting in an org that is cluttered and unscalable. Finding the relationships between metadata components in your org can help you reduce complexity and unclutter your Salesforce org.

How: In previous releases, this type of query was accessible using Tooling API only. You can now query the MetadataComponentDependency object using Tooling API endpoints in Bulk API 2.0. To create a query job, issue a REST API POST request and include your SOQL query statement in the body of the request. For example,

URI:
/services/data/v49.0/tooling/jobs/query HTTP/1.1
Request Body:
{
  "operation": "query",
  "query": "select MetadataComponentType FROM MetadataComponentDependency“
}
  • Only queries against the MetadataComponentDependency object are supported using the /services/data/vXX.X/tooling endpoint in Bulk API 2.0.
  • Requests are returned in CSV format.
  • You can also filter your query by adding a WHERE clause to narrow the results.

The following table lists the URIs and methods supported by Bulk API 2.0 for MetadataComponentDependency queries.

Description URI HTTP Method
Creates a query job. /services/data/vXX.X/tooling/jobs/query POST
Gets information about all query jobs in the org. /services/data/vXX.X/tooling/jobs/query GET
Gets information about one query job. /services/data/vXX.X/tooling/jobs/query/queryJobId GET
Gets the results for a query job. /services/data/vXX.X/tooling/jobs/query/queryJobId/results GET
Aborts a query job. /services/data/vXX.X/tooling/jobs/query/queryJobId PATCH
Deletes a query job. /services/data/vXX.X/tooling/jobs/query/queryJobId DELETE

The following SOQL queries are not supported.

  • SOQL ORDER BY clause
  • SOQL SELECT clause—count() function
  • SOQL queryMore()
  • SOQL WHERE clause—Any type of filter with MetadataComponentName
  • SOQL WHERE clause—Any type of filter with RefMetadataComponentName
  • SOQL WHERE clause—Contains operators other than =, !=, AND, or OR
  • SOQL WHERE clause—Filter by (RefMetadataComponentType = 'StandardEntity')
  • SOQL WHERE clause—Use of the LIKE operator with either the MetadataComponentType field or RefMetadataComponentType field
  • SOQL OFFSET clause