Utilizing the Tooling API to Query Deployment Information


Hello, and welcome to Another Salesforce Blog!  Here I will be posting solutions to problems that I couldn’t find an answer to in hopes of helping those who find themselves stuck when using the Salesforce platform.

User Story

Today we are going to cover a worst case scenario. Something was deployed to Production that shouldn’t have been, but we don’t know which deployment holds the answer. The UI for deployments is clunky and doesn’t allow us to see who deployed what without clicking into the individual deployment. This is a hassle, especially when the clock is ticking!

Using the Tooling API DeployRequest object, which is unfortunately not listed in the Salesforce documentation as of the writing of this post, we can query who deployed what and when to narrow down our search.

Background

The Tooling API allows us to query for different metadata types to retrieve smaller pieces of metadata. Per the Salesforce documentation, we want to use the Tooling API when we need “fine-grained access to an org’s metadata.”

Solution

In order to solve for this, we are going to enter into the Developer Console in the org that we want to query from. From the Developer Console, we are going to navigate to the Query Editor, and check the “Use Tooling API” box by the “Execute” button.

Screenshot of the Developer Console Query Editor

From here, we are going to enter the following query:

SELECT Id, Status, StartDate, CompletedDate, createdBy.Name FROM DeployRequest

This will give us the ID of the DeployRequest record, the Status, pertinent date information, and the name of who initiated the deployment in the org.

Screenshot of the query results showing the ID, Status, Start Date, Completed Date, and CreatedBy.Name for the DeployRequest records queried.

Unfortunately, we are not able to specify a WHERE clause in our query as of this writing – doing so results in an unspecified query error.

To complete this in WorkBench using the REST Explorer, we can use the following URI with a GET call:

/services/data/v53.0/tooling/query/?q=SELECT+Id,+Status,+StartDate,+CompletedDate,+createdBy.Name+FROM+DeployRequest
Screenshot of Workbench REST Explorer

This makes for a more manageable set of data, as we can show the Raw Response in Workbench and manipulate it accordingly.

Thanks for reading, let me know if you have any comments or questions!

-Evelyn, Another Salesforce Blog

One-Time
Monthly
Yearly

Make a one-time donation

Make a monthly donation

Make a yearly donation

Choose an amount

$5.00
$15.00
$50.00
$5.00
$15.00
$50.00
$5.00
$15.00
$50.00

Or enter a custom amount

$

Help keep Another Salesforce Blog on the internet by donating today!

Your contribution is appreciated.

Your contribution is appreciated.

DonateDonate monthlyDonate yearly
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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

%d bloggers like this: