Newer Version Available

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

renameMetadata()

Renames a metadata component in your organization synchronously.

Syntax

1SaveResult = metadataConnection.renameMetadata(string metadataType, String oldFullname, String newFullname);

Usage

Use the renameMetadata() call to rename one metadata component in your organization. This call executes synchronously, meaning the call returns only when the operation completes.

You can use this call to rename 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.

Basic Steps for Renaming Metadata Components

Use the following process to rename a metadata component:

  1. Determine the metadata type of the component you want to rename, its current full name, and the new full name. See Metadata for more details on the fullName field.
  2. Invoke the renameMetadata() call. For the first argument, pass in the name of the metadata type. Pass in the old full name as the second argument and the new full name as the last argument.

    A SaveResult object is returned that contains information about whether the operation was successful, the name of the renamed component (which is the new name if the renaming was successful), and any errors returned if the operation wasn’t successful.

Sample Code—Java

1swfobject.registerObject("clippy.codeblock-1", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17public void renameCustomObjectSync() {
18 try {
19    SaveResult[] results = metadataConnection.renameMetadata(
20        "CustomObject", "MyCustomObject1__c","MyCustomObject1New__c");
21    for (SaveResult r : results) {
22    	if (r.isSuccess()) {
23    		System.out.println("Renamed component: " + r.getName());
24    	}
25    	else {
26    		System.out.println("Errors were encountered while renaming " + r.getName());
27    		for(Error e : r.getErrors()) {
28    			System.out.println("Error message: " + e.getMessage());
29    			System.out.println("Status code: " + e.getStatusCode());
30    		}
31    	}
32    }
33  } catch (ConnectionException ce) {
34    ce.printStackTrace();
35  } catch (InterruptedException ie) {
36    ie.printStackTrace();
37  }
38}

Arguments

Name Type Description
metadataType string The metadata type of the components to rename.
oldFullName string The current component full name.
newFullName string The new component full name.

Response

SaveResult