1

I want to pull metadata from a sandbox for the purpose of finding where in code a standard field is being referenced. My plan is to pull the meta-data and then search for references to the field.

Currently using sfdx I am able to pull apexclass using command

sfdx force:mdapi:retrieve -r ./mdapipkg -u <username> -k ./package.xml

My package.xml is like this:

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>sotestcontroller</members>
        <name>ApexClass</name>
    </types>
    <version>42.0</version>
</Package>

This returns the class in question, but I don't want to have to manually add in all the classes to get the data. I tried using this - https://marketplace.visualstudio.com/items?itemName=VignaeshRamA.sfdx-package-xml-generator visual studio code plugin but it just seemed to hang for ages and didn't generate anything.

What is the easiest way to get the metadata?

  • 2
    You can give wild character for member attribute and retrieve all the classes right. Are you saying it's not working? – Raj Feb 20 at 14:06
  • I did not know that. – eaeaoo Feb 20 at 14:10
  • 2
    Oh, okie. Just give a wild character and you should be able to retrieve all classes at once. Wild character do not work for all the types of metadata but i know that it surely works for ApecClass. Good luck – Raj Feb 20 at 14:12
  • 1
    You can also query for such dependencies using a Dependency API query. I can explain more if you're interested – Bow-chicawow-ers Feb 20 at 14:45
  • 1
    ApexcClass supports wild character(*) , just replace sotestcontroller with * in your package.xml . other way you can try in developer console edit-->Search in files – sdandamud1 Feb 20 at 16:14
1

Here is the resource URL from Salesforce : https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_classes.htm

To fetch all the class, you just need to include the below lines in your package.xml:

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
    <members>*</members>
    <name>ApexClass</name>
</types>
<version>48.0</version>

This metadata type supports the wildcard character * (asterisk) in the package.xml manifest file.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.