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

FileProperties[] = 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.

This call is synchronous, so the results are returned in one call. This call differs from asynchronous calls, such as retrieve(), where at least one subsequent call is required to get the results.

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

Sample Code—Java

This sample code lists information about your custom objects. The code assumes that the SOAP binding has already been established.

public void listMetadata() {
  try {
    ListMetadataQuery query = new ListMetadataQuery();
    query.setType("CustomObject");
    //query.setFolder(null);
    double asOfVersion = 63.0;
    // Assuming that the SOAP binding has already been established.
    FileProperties[] lmr = metadataConnection.listMetadata(
        new ListMetadataQuery[] {query}, asOfVersion);
    if (lmr != null) {
      for (FileProperties n : lmr) {
        System.out.println("Component fullName: " + n.getFullName());
        System.out.println("Component type: " + n.getType());
      }
    }            
  } catch (ConnectionException ce) {
    ce.printStackTrace();
  }
}

Arguments

Name Type Description
queries ListMetadataQuery[] A list of objects that specify which components you’re 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.

Response

FileProperties