Let us know so we can improve!
The online Trailblazer Community is now read-only. [Read the FAQ] [Get Help]
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.
1FileProperties[] = metadataConnection.listMetadata(ListMetadataQuery[] queries, double asOfVersion);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 Declarative (File-Based) Metadata API Calls.
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.
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
This sample code 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 = 68.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}