DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!
Let us know so we can improve!
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.
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);Use this call to update one or more components. This call is analogous to the ALTER TABLE statement in SQL.
This call is available in API version 30.0 and earlier only. This call isn’t available in API version 31.0 and later. Use updateMetadata() instead to update metadata components or renameMetadata() to rename a metadata component.
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
You must supply values for all the required fields in the component.
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).
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".
Use this process to update metadata components:
UpdateMetadata components, and populate it with the components you want to update. All components must be of the same type.update() call, passing in the array of metadata components to update.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}Type: UpdateMetadata[]
Description: 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.
One or more UpdateMetadata objects are defined in the metadata argument. This object can be used to update any of the objects that extend . For more details, see Metadata Components and Types. Each UpdateMetadata object has the following fields:
Foo__c. This value is supplied because this call can change the name, and the value here provides mapping.