No Results
Search Tips:
- Please consider misspellings
- Try different search keywords
Newer Version Available
updateMetadata()
Syntax
1SaveResult[] = metadataConnection.updateMetadata(Metadata[] metadata);Usage
Use the updateMetadata() call to update one or more metadata components in your organization. This call executes synchronously, meaning the call returns only when the operation completes.
You can use this call to update any of the objects that extend Metadata. For more details, see Metadata Components and Types.
Version
Available in API version 30.0 and later.
Permissions
Your client application must be logged in with the “Modify All Data” permission.
Required Fields
You must supply values for all the required fields in the component.
Valid Field Values
You must supply values that are valid for the field’s data type, such as integers for integer fields (not alphabetic characters). In your client application, follow the data formatting rules specified for your programming language and development tool (your development tool handles the appropriate mapping of data types in SOAP messages).
String Values
When storing values in string fields, the API trims any leading and trailing white space. For example, if the value of a label field is entered as "MyObject " the value is stored in the database as "MyObject".
Basic Steps for Updating Metadata Components
- Create an array of the components you wish to update. All components must be of the same type.
- Invoke the updateMetadata() call, passing in the array of metadata components to update.
A SaveResult object is returned for each component you tried to update. It contains information about whether the operation was successful, the name of the component updated, and any errors returned if the operation wasn’t successful.
Sample Code—Java
1swfobject.registerObject("clippy.codeblock-1", "9");public void updateCustomObjectSync() {
2 try {
3 CustomObject co = new CustomObject();
4 String name = "MyCustomObject1";
5 co.setFullName(name + "__c");
6 co.setDeploymentStatus(DeploymentStatus.Deployed);
7 co.setDescription("Updated description");
8 co.setLabel(name + " Object Update");
9 co.setPluralLabel(co.getLabel() + "s");
10 co.setSharingModel(SharingModel.ReadWrite);
11
12 // Name field with a type and label is required
13 CustomField cf = new CustomField();
14 cf.setType(FieldType.Text);
15 cf.setLabel(co.getFullName() + " Name");
16 co.setNameField(cf);
17
18 SaveResult[] results = metadataConnection
19 .updateMetadata(new Metadata[] { co });
20
21 for (SaveResult r : results) {
22 if (r.isSuccess()) {
23 System.out.println("Updated component: " + r.getFullName());
24 } else {
25 System.out
26 .println("Errors were encountered while updating "
27 + r.getFullName());
28 for (Error e : r.getErrors()) {
29 System.out.println("Error message: " + e.getMessage());
30 System.out.println("Status code: " + e.getStatusCode());
31 }
32 }
33 }
34 } catch (ConnectionException ce) {
35 ce.printStackTrace();
36 }
37}Arguments
| Name | Type | Description |
|---|---|---|
| metadata | Metadata[] | Array of one or more metadata components you wish to update. 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. |