Newer Version Available
listMetadata()
This call retrieves property information about metadata components in your
organization. Data is returned for the components that match the criteria specified in the
queries parameter. The queries array can contain up to three ListMetadataQuery queries for each call. This call supports every metadata type:
both top-level, such as CustomObject and ApexClass, and child types, such as CustomField and
RecordType.
Syntax
1FileProperties[] = metadataConnection.listMetadata(ListMetadataQuery[] queries, double asOfVersion);Usage
This call is useful when you want to identify individual components in
package.xml for a retrieve() call or if you want a
high-level view of particular metadata types in your organization. For example, you can use
this call to return a list of names of all the CustomObject or Layout components in
your organization. You can use this information to make a subsequent retrieve() call to return a subset of
these components. For more information about working with package.xml,
see Deploying and Retrieving Metadata.
Permissions
Your client application must be logged in with the Modify Metadata Through Metadata API Functions or Modify All Data permission.
Sample Code—Java
The sample code below lists information about your custom objects. The code assumes that the SOAP binding has already been established.
1public void listMetadata() {
2 try {
3 ListMetadataQuery query = new ListMetadataQuery();
4 query.setType("CustomObject");
5 //query.setFolder(null);
6 double asOfVersion = 54.0;
7 // Assuming that the SOAP binding has already been established.
8 FileProperties[] lmr = metadataConnection.listMetadata(
9 new ListMetadataQuery[] {query}, asOfVersion);
10 if (lmr != null) {
11 for (FileProperties n : lmr) {
12 System.out.println("Component fullName: " + n.getFullName());
13 System.out.println("Component type: " + n.getType());
14 }
15 }
16 } catch (ConnectionException ce) {
17 ce.printStackTrace();
18 }
19}Arguments
| Name | Type | Description |
|---|---|---|
| queries | ListMetadataQuery[] | A list of objects that specify which components you are interested in. |
| asOfVersion | double | The API version for the metadata listing request. If you don't specify a value in this field, it defaults to the API version specified when you logged in. This field allows you to override the default and set another API version. For example, you can list the metadata for a metadata type that was added in a later version than the API version specified when you logged in. This field is available in API version 18.0 and later. |