No Results
Search Tips:
- Please consider misspellings
- Try different search keywords
Newer Version Available
deleteMetadata()
Syntax
1DeleteResult[] = metadataConnection.delete(string metadataType, string[] fullNames);Usage
Use the deleteMetadata() call to delete any component that extends Metadata. All components must be of the same type in the same call. For more details, see Metadata Components and Types.
This call executes synchronously, which means that the call returns only when the operation completes.
Version
Available in API version 30.0 and later.
Permissions
Your client application must be logged in with the “Modify All Data” permission.
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 SOAP API Developer's Guide.
- In addition, you might 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:
- Determine the metadata type of the components you want to delete and the fullName of each component to delete. You can delete only components of the same type in a single call. The full names must match one or more full names returned by the listMetadata() call. See Metadata for more details on the fullName field.
- Invoke the deleteMetadata() call. For the first argument, pass in the name of the metadata type.
For the second argument, pass in an array of full names corresponding
to the components you wish to delete.
A DeleteResult object is returned for each component you try to delete. It contains information about whether the operation was successful, the name of the deleted component, and any errors returned if the operation wasn’t successful.
Sample Code—Java
1swfobject.registerObject("clippy.codeblock-1", "9");public void deleteCustomObjectSync() {
2 try {
3 DeleteResult[] results = metadataConnection.deleteMetadata(
4 "CustomObject", new String[] { "MyCustomObject1__c",
5 "MyCustomObject2__c" });
6 for (DeleteResult r : results) {
7 if (r.isSuccess()) {
8 System.out.println("Deleted component: " + r.getFullName());
9 } else {
10 System.out
11 .println("Errors were encountered while deleting "
12 + r.getFullName());
13 for (Error e : r.getErrors()) {
14 System.out.println("Error message: " + e.getMessage());
15 System.out.println("Status code: " + e.getStatusCode());
16 }
17 }
18 }
19 } catch (ConnectionException ce) {
20 ce.printStackTrace();
21 }
22}