delete()

Deprecated. Deletes one or more components from your organization asynchronously. This call is removed as of API version 31.0 and is available in earlier versions only. Use deleteMetadata() instead.
You can use this call to delete any of the objects that extend Metadata. For more details, see Metadata Components and Types.

Syntax

AsyncResult[] = metadataConnection.delete(Metadata[] metadata);

Usage

Use this call to delete one or more components from your organization.

Version

This call is available in API version 30.0 and earlier only. This call isn’t available in API version 31.0 and later. Use deleteMetadata() instead.

Permissions

Your client application must be logged in with the Modify Metadata Through Metadata API Functions or Modify All Data permission.

If a user requires access to metadata but not to data, enable the Modify Metadata Through Metadata API Functions permission. Otherwise, enable the Modify All Data permission.

Note

Rules and Guidelines

When deleting components, consider the following rules and guidelines:

  • Your client application must be logged in with sufficient access rights to delete individual components within the specified component. For more information, see Factors that Affect Data Access in the Salesforce Object Reference.
  • In addition, sometimes you also need permission to access this component’s parent component.
  • To ensure referential integrity, this call supports cascading deletions. If you delete a parent component, you delete its children automatically, as long as each child component can be deleted.

Basic Steps for Deleting Metadata Components

Use the following process to delete metadata components:

  1. Determine the fullName of each component you want to delete. See Metadata for more details on the fullName field. You can only delete components of the same type in a single call.
  2. Invoke the delete() call, passing in the array of metadata components with fullName specified.
  3. An AsyncResult object is returned for each component you try to delete, and is updated with status information as the operation moves from a queue to completed or error state. Call checkStatus() in a loop until the status values in AsyncResult indicate that all the delete operations are completed. Start with a wait time of 1 second between iterations of checkStatus() calls, and double the wait time each time you make a subsequent call.

Sample Code—Java

public void deleteCustomObject() {
  try {
    CustomObject co = new CustomObject();
    co.setFullName("MyCustomObject__c");
    AsyncResult[] ars = metadataConnection.create(new Metadata[]
       {co});
    AsyncResult asyncResult = ars[0];
    long waitTimeMilliSecs = 1000;
    while (!asyncResult.isDone()) {
      Thread.sleep(waitTimeMilliSecs);
      // double the wait time for the next iteration
      waitTimeMilliSecs *= 2;
      asyncResult = mdConnection.checkStatus(
        new String[] {asyncResult.getId()})[0];
      System.out.println("Status is: " + asyncResult.getState());
    }
  } catch (ConnectionException ce) {
    ce.printStackTrace();
  } catch (InterruptedException ie) {
    ie.printStackTrace();
  }
}

Arguments

Name Type Description
metadata Metadata[]

Array of one or more metadata components. Only set the fullName field in the Metadata object.

Limit: 10.

You must submit arrays of only one type of component. For example, you could submit an array of 10 custom objects or 10 profiles, but not a mix of both types.

Response

AsyncResult[]