No Results
Search Tips:
- Please consider misspellings
- Try different search keywords
Newer Version Available
readMetadata()
Syntax
1ReadResult = metadataConnection.readMetadata(string metadataType, string[] fullNames);Usage
Use the readMetadata() call to get one or more metadata components from your organization. This call executes synchronously, meaning the call returns only when the operation completes.
You can use this call to retrieve 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 Reading Metadata Components
Use the following process to read metadata components:
- Determine the metadata type of the components you want to read, and the fullName of each component to read. See Metadata for more details on the fullName field. You can read only components of the same type in a single call.
- Invoke the readMetadata() call. For the first argument, pass in the name of the metadata type. The metadata type must match one of the values returned by the describeMetadata() call. For the second argument, pass in an array of full names corresponding to the components you wish to get. The full names must match one or more full names returned by the listMetadata() call.
- A ReadResult is returned that contains an array of Metadata components. Cast each returned Metadata object to the metadata type you specified in the call to get the component’s properties.
Sample Code—Java
1swfobject.registerObject("clippy.codeblock-1", "9");public void readCustomObjectSync() {
2 try {
3 ReadResult readResult = metadataConnection
4 .readMetadata("CustomObject", new String[] {
5 "MyCustomObject1__c", "MyCustomObject2__c" });
6 Metadata[] mdInfo = readResult.getRecords();
7 System.out.println("Number of component info returned: "
8 + mdInfo.length);
9 for (Metadata md : mdInfo) {
10 if (md != null) {
11 CustomObject obj = (CustomObject) md;
12 System.out.println("Custom object full name: "
13 + obj.getFullName());
14 System.out.println("Label: " + obj.getLabel());
15 System.out.println("Number of custom fields: "
16 + obj.getFields().length);
17 System.out.println("Sharing model: "
18 + obj.getSharingModel());
19 } else {
20 System.out.println("Empty metadata.");
21 }
22 }
23 } catch (ConnectionException ce) {
24 ce.printStackTrace();
25 }
26}