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 Callsupdate<strong>Metadata</strong>()update<strong>Metadata</strong>()Updates one or more metadata <strong>com</strong>ponents in your organization synchronously.SyntaxSaveResult[] = metadataConnection.update<strong>Metadata</strong>(<strong>Metadata</strong>[] metadata);UsageUse the update<strong>Metadata</strong>() call to update one or more metadata <strong>com</strong>ponents in your organization. This call executessynchronously, meaning the call returns only when the operation <strong>com</strong>pletes.You can use this call to update any of the objects that extend <strong>Metadata</strong>. For more details, see <strong>Metadata</strong> Components andTypes.VersionAvailable in <strong>API</strong> version 30.0 and later.PermissionsYour client application must be logged in with the “Modify All Data” permission.Required FieldsYou must supply values for all the required fields in the <strong>com</strong>ponent.Valid Field ValuesYou must supply values that are valid for the field’s data type, such as integers for integer fields (not alphabetic characters). Inyour client application, follow the data formatting rules specified for your programming language and development tool (yourdevelopment tool handles the appropriate mapping of data types in SOAP messages).String ValuesWhen storing values in string fields, the <strong>API</strong> trims any leading and trailing white space. For example, if the value of a labelfield is entered as "MyObject " the value is stored in the database as "MyObject".Basic Steps for Updating <strong>Metadata</strong> ComponentsUse this process to update metadata <strong>com</strong>ponents:1. Create an array of the <strong>com</strong>ponents you wish to update. All <strong>com</strong>ponents must be of the same type.2. Invoke the update<strong>Metadata</strong>() call, passing in the array of metadata <strong>com</strong>ponents to update.A SaveResult object is returned for each <strong>com</strong>ponent you tried to update. It contains information about whether theoperation was successful, the name of the <strong>com</strong>ponent updated, and any errors returned if the operation wasn’t successful.Sample Code—Javapublic void updateCustomObjectSync() {try {CustomObject co = new CustomObject();String name = "MyCustomObject1";co.setFullName(name + "__c");co.setDeploymentStatus(DeploymentStatus.Deployed);50

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

Saved successfully!

Ooh no, something went wrong!