9

How can I retrieve custom fields from standard objects using:

sfdx force:source:retrieve -m

I tried using CustomField to no avail.

I am trying to pull the custom fields I have added from a non-tracked org (i.e. a non-scratch org) that only supports MDAPI directly into the newer SFDX format.

  • This seems like a pretty clearly asked question. Why is this closed as "unclear"? – torpy Oct 8 '19 at 15:27
  • 1
    I've noticed this trend quite some time ago. Mods that never had any serious exposure to certain aspects of Salesforce have no idea about the question. Particularly bad when asking developer questions and clueless admins kill questions down. Also super annoying when people ask for code samples when question was clearly a conceptual one. – dzh Oct 11 '19 at 4:48
  • Yeah this was closed by the community, not a moderator. Going to re-open it because was about to ask this exact question myself, it has all the information it needs. – Matt Lacey Jan 21 at 0:10
9

This syntax was what I needed

sfdx force:source:retrieve -m CustomField:Claim.CveClaim__c

to retrieve my custom field CveClaim__c that I added to the (standard in FSC object) Claim. The -m CustomObject:Account will pull back all the fields of that object - standard and custom.

| improve this answer | |
3

You have to specifically name the objects you want, e.g. -m CustomObject:Account,Opportunity

Alternatives I know of:

1) Use this VSCode plugin to easily produce a package.xml by point and click, then retrieve against that.

https://marketplace.visualstudio.com/items?itemName=VignaeshRamA.sfdx-package-xml-generator

2) Use shane-sfdx-plugins which supports a syntax sfdx shane:mdapi:pull --type=CustomObject but will actually pull standard objects too.

https://github.com/mshanemc/shane-sfdx-plugins

| improve this answer | |
  • 2
    As I can't post this more clearly because the question is closed, let me add that this syntax was what I needed sfdx force:source:retrieve -m CustomField:Claim.CveClaim__c to retrieve my custom field CveClaim__c that I added to the (standard in FSC object) Claim. The -m CustomObject:Account will pull back all the fields of that object - standard and custom. – Keith C Sep 27 '19 at 17:51
  • That's fine if you want all the fields of the object, but sometimes it's more desirable to pull just the specific field from the object. In which case Keith C has provided a nice example of what command to use. – torpy Oct 8 '19 at 15:29
  • @KeithC Can you post this as an asnwer now? I just re-opened the question and your comment here is the exact answer I was after. Also, ping me when you do so I can up-vote :) – Matt Lacey Jan 21 at 0:11
  • @MattLacey Done. – Keith C Jan 21 at 8:39

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.