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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CRUD-Based Callsupdate()1. Determine the fullName of each <strong>com</strong>ponent you want to delete. See <strong>Metadata</strong> for more details on the fullName field.You can only delete <strong>com</strong>ponents of the same type in a single call.2. Invoke the delete() call, passing in the array of metadata <strong>com</strong>ponents with fullName specified.3. An AsyncResult object is returned for each <strong>com</strong>ponent you try to delete, and is updated with status information as theoperation moves from a queue to <strong>com</strong>pleted or error state. Call checkStatus() in a loop until the status values inAsyncResult indicate that all the delete operations are <strong>com</strong>pleted. Start with a wait time of one second between iterationsof checkStatus() calls, and double the wait time each time you make a subsequent call.Sample Code—Javapublic void deleteCustomObject() {try {CustomObject co = new CustomObject();co.setFullName("MyCustomObject__c");AsyncResult[] ars = metadataConnection.create(new <strong>Metadata</strong>[]{co});AsyncResult asyncResult = ars[0];long waitTimeMilliSecs = 1000;while (!asyncResult.isDone()) {Thread.sleep(waitTimeMilliSecs);// double the wait time for the next iterationwaitTimeMilliSecs *= 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();}}ArgumentsNamemetadataType<strong>Metadata</strong>[]DescriptionArray of one or more metadata <strong>com</strong>ponents. You only need to set the fullName fieldin the <strong>Metadata</strong> object.Limit: 10.You must submit arrays of only one type of <strong>com</strong>ponent. For example, you could submitan array of 10 custom objects or 10 profiles, but not a mix of both types.ResponseAsyncResult[]update()Updates one or more <strong>com</strong>ponents in your organization asynchronously.This call can be used to update any of the objects that extend <strong>Metadata</strong>. For more details, see <strong>Metadata</strong> Components andTypes on page 75.SyntaxAsyncResult[] = metadataConnection.update(Update<strong>Metadata</strong>[] metadata);44

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

Saved successfully!

Ooh no, something went wrong!