12.07.2015 Views

Database.com Metadata API Developer's Guide - Salesforce.com

Database.com Metadata API Developer's Guide - Salesforce.com

Database.com Metadata API Developer's Guide - Salesforce.com

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CRUD-Based Callsdelete<strong>Metadata</strong>()VersionAvailable in <strong>API</strong> version 30.0 and later.PermissionsYour client application must be logged in with the “Modify All Data” permission.Rules and <strong>Guide</strong>linesWhen deleting <strong>com</strong>ponents, consider the following rules and guidelines:• Your client application must be logged in with sufficient access rights to delete individual <strong>com</strong>ponents within the specified<strong>com</strong>ponent. For more information, see “Factors that Affect Data Access” in the SOAP <strong>API</strong> <strong>Developer's</strong> <strong>Guide</strong>.• In addition, you might also need permission to access this <strong>com</strong>ponent’s parent <strong>com</strong>ponent.• To ensure referential integrity, this call supports cascading deletions. If you delete a parent <strong>com</strong>ponent, you delete itschildren automatically, as long as each child <strong>com</strong>ponent can be deleted.Basic Steps for Deleting <strong>Metadata</strong> ComponentsUse the following process to delete metadata <strong>com</strong>ponents:1. Determine the metadata type of the <strong>com</strong>ponents you want to delete and the fullName of each <strong>com</strong>ponent to delete. Youcan delete only <strong>com</strong>ponents of the same type in a single call. The full names must match one or more full names returnedby the list<strong>Metadata</strong>() call. See <strong>Metadata</strong> for more details on the fullName field.2. Invoke the delete<strong>Metadata</strong>() call. For the first argument, pass in the name of the metadata type. For the secondargument, pass in an array of full names corresponding to the <strong>com</strong>ponents you wish to delete.A DeleteResult object is returned for each <strong>com</strong>ponent you try to delete. It contains information about whether theoperation was successful, the name of the deleted <strong>com</strong>ponent, and any errors returned if the operation wasn’t successful.Sample Code—Javapublic void deleteCustomObjectSync() {try {DeleteResult[] results = metadataConnection.delete<strong>Metadata</strong>("CustomObject", new String[] { "MyCustomObject1__c","MyCustomObject2__c" });for (DeleteResult r : results) {if (r.isSuccess()) {System.out.println("Deleted <strong>com</strong>ponent: " + r.getFullName());} else {System.out.println("Errors were encountered while deleting "+ r.getFullName());for (Error e : r.getErrors()) {System.out.println("Error message: " + e.getMessage());System.out.println("Status code: " + e.getStatusCode());}}}} catch (ConnectionException ce) {ce.printStackTrace();}}ArgumentsNamemetadataTypeTypestringDescriptionThe metadata type of the <strong>com</strong>ponents to delete.52

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!