Is there a simple way to use the sfdx
CLI to retrieve and deploy new custom fields from one org to another?
Use case: Someone creates new custom fields in Production and want to deploy them easily to other sandboxes without having to go to change sets or doing a full sandbox refresh.
Potential Approach: I know we can grab a new custom field via:
sfdx force:source:retrieve -m CustomField:Account.New_Custom_Field__c -u MyProductionOrg
But I am looking to also "grab" the relevant Profile FLS settings along with this field (but not the whole Profile
metadata file), then figure I could deploy via something like:
sfdx force:source:deploy -m CustomField:Account.New_Custom_Field__c,Profile -u MySandboxOrg
What am I missing?
Best Answer
If you're using a Scratch Org, just
force:source:pull
, and the related profile settings will be retrieved.If you're using a non-Scratch Org (Developer, Sandbox), retrieve the fields and profiles in one command:
That said, you should probably consider moving to Permission Sets (and Permission Set Groups), which is a lot more portable when you get to using Unlocked Packages.