Contact Us

November 11, 2024

May 13, 2026 3:58 pm

Deleting custom objects in Salesforce using Agentforce

Share with

Understanding the Problem

The error message received when attempting to delete a custom object through the agent is due to insufficient access rights. However, even with the correct permissions, the Tooling API will not support custom object deletion.

The root cause of this issue is the limitation of the Tooling API in Salesforce, which does not support deleting custom objects.

Alternative Methods

As suggested by the community, the Metadata API can be used as an alternative method to delete custom objects. This can be done by deploying with destructive changes or using the delete metadata API.

metadata-api-example

// Example of using the Metadata API to delete a custom object
// Note: This is a simplified example and may require additional error handling and authentication
MetadataService metadataService = new MetadataService();
DeleteResult[] deleteResults = metadataService.deleteMetadata('CustomObject', new String[] {'ObjectName'});

Implementation Steps

To implement this alternative method, teams will need to authenticate with the Metadata API and make the necessary SOAP calls to delete the custom object.

Heads up: This method requires additional work to authenticate and make the SOAP calls, but it provides a viable alternative to deleting custom objects in Salesforce.

Checklist

Steps to Delete Custom Objects using Metadata API

  • Authenticate with the Metadata API
  • Use the delete metadata API to delete the custom object
  • Handle any errors that may occur during the deletion process
  • Verify that the custom object has been successfully deleted
  • Test the deletion process to ensure it works as expected

Frequently Asked Questions

What is the Metadata API?

The Metadata API is a Salesforce API that allows you to manage and manipulate metadata, such as custom objects, fields, and pages.

Can I use the Tooling API to delete custom objects?

No, the Tooling API does not support deleting custom objects. You must use the Metadata API instead.

Do I need to authenticate with the Metadata API?

Yes, you must authenticate with the Metadata API before you can use it to delete custom objects.

What are the benefits of using the Metadata API?

The Metadata API provides a powerful and flexible way to manage and manipulate metadata in Salesforce, including deleting custom objects.

Genetrix Technology · Salesforce Marketing Cloud Partner

Need help shipping this in production?

Genetrix builds and untangles Salesforce Marketing Cloud and Agentforce setups for teams that want it done right the first time. If anything in this post sounds familiar, talk to us before it ships.

Get in Touch with Genetrix →

Blogs for the

Business-Savvy!​

Let’s Connect

A 30 min no cost strategy session
with cloud support expert

Let’s Connect

A 30 min no cost strategy session
with cloud support expert