Newer Version Available

This content describes an older version of this product. View Latest

update()

Deprecated. Updates one or more components in your organization asynchronously. This call is removed as of API version 31.0 and is available in earlier versions only. Use updateMetadata() or renameMetadata() instead.

Syntax

This call can be used to update any of the objects that extend Metadata. For more details, see Metadata Components and Types.
1AsyncResult[] = metadataConnection.update(UpdateMetadata[] metadata);

Usage

Use this call to update one or more components. This call is analogous to the ALTER TABLE statement in SQL.

Version

This call is available in API version 30.0 and earlier only. This call is not available in API version 31.0 and later. Use updateMetadata() instead to update metadata components or renameMetadata() to rename a metadata component.

Permissions

Your client application must be logged in with the Modify Metadata Through Metadata API Functions or Modify All Data permission.

If a user requires access to metadata but not to data, enable the Modify Metadata Through Metadata API Functions permission. Otherwise, enable the Modify All Data permission.

Note

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

Use this process to update metadata components:
  1. Create an array of UpdateMetadata components, and populate it with the components you want to update. All components must be of the same type.
  2. Invoke the update() call, passing in the array of metadata components to update.
  3. An AsyncResult object is returned for each component you try to update, and is updated with status information as the operation moves from a queue to completed or error state. In a loop, call checkStatus() until the status values in AsyncResult indicate that all the update operations are completed. Start with a wait time of 1 second between iterations of checkStatus() calls, and double the wait time each time you make a subsequent call.

Sample Code—Java

1public void updateCustomObject() {
2  try {
3    CustomObject co = new CustomObject();
4    String name = "MyCustomObject";
5    co.setFullName(name + "__c");
6    co.setDeploymentStatus(DeploymentStatus.Deployed);
7    co.setDescription("Created by the Metadata API");
8    co.setEnableActivities(true);
9    co.setLabel(name + " Object");
10    co.setPluralLabel(co.getLabel() + "s");
11    co.setSharingModel(SharingModel.ReadWrite);
12    
13    CustomField nf = new CustomField();
14    nf.setType(FieldType.Text);
15    nf.setLabel(co.getFullName() + " Name");
16    
17    co.setNameField(nf);
18    
19    UpdateMetadata updateMetadata = new UpdateMetadata();
20    updateMetadata.setMetadata(co);
21    updateMetadata.setCurrentName("TheCurrentName");
22    
23    AsyncResult[] ars = metadataConnection.update(new UpdateMetadata[] 
24        { updateMetadata });
25    AsyncResult asyncResult = ars[0];
26    // set initial wait time to one second in milliseconds
27    long waitTimeMilliSecs = 1000;
28    while (!asyncResult.isDone()) {
29      Thread.sleep(waitTimeMilliSecs);
30      // double the wait time for the next iteration
31      waitTimeMilliSecs *= 2;
32      asyncResult = metadataConnection.checkStatus(
33        new String[] {asyncResult.getId()})[0];
34      System.out.println("Status is: " + asyncResult.getState());
35    }
36    
37    if (asyncResult.getState() != AsyncRequestState.Completed) {
38      System.out.println(asyncResult.getStatusCode() + " msg: " +
39          asyncResult.getMessage());
40    }
41  } catch (InterruptedException ie) {
42    ie.printStackTrace();
43  } catch (ConnectionException ce) {
44    ce.printStackTrace();
45  }
46}

Arguments

Name Type Description
metadata UpdateMetadata[] Array of one or more UpdateMetadata data structures that represent the 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.

UpdateMetadata

One or more UpdateMetadata objects are defined in the metadata argument. This object can be used to update any of the objects that extend Metadata. For more details, see Metadata Components and Types. Each UpdateMetadata object has the following fields:

Field Field Type Description
currentName string The API name of the component or field before the update. For example, if you wanted to update a CustomObject named Foo, the value of this field would be Foo__c. This value is supplied because this call can change the name, and the value here provides mapping.
metadata Metadata Full specification of the component or field you want to update.

Response

AsyncResult[]