1

I am trying calling readMetadata() method in java to return all instances of a metadata type in my sandbox: For example calling readMetadata("ApexClass") will return the api names of all apex classes in my org. As you can see, I am attempting to use the "*" wildcard here but that doesn't seem to work.

PS: This method works if I call metadataConnection.readMetadata("CustomObject",new String[] { "Account" });

I want to make it generic enough to be able to just provide the metadata type and get all instances of it.

public static void readData(String metadataType) {
    try {
        ReadResult readResult = metadataConnection.readMetadata(metadataType,new String[] { "*" });
        Metadata[] mdInfo = readResult.getRecords();

        for (Metadata md : mdInfo) {
            if (md != null) {
                //parse results into a list
            } else {
                System.out.println("Empty metadata.");
            }
        }
    } catch (ConnectionException ce) {
        ce.printStackTrace();
    }
}
0

1 Answer 1

4

Based on the documentation on readMetadata(), it does not seem like wildcard selection is possible, since the limit on returned results is 10.

Arguments

  • Name fullNames
  • Type string[]
  • Description Array of full names of the components to read.
    Limit: 10. (For CustomMetadata only, the limit is 200.)

    You must submit arrays of only one type of component. For example, you can submit an array of 10 custom objects or 10 profiles, but not a mix of both types.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .