How to Import a Specific Field Into a Project in SFDX
Many times, as part of developing new functionality, we create a new field in our development environment and later want to import it into our project so that we can deploy it directly from Visual Studio Code to a higher environment. The solution is simple: writing the command to import a custom field and specifying the reference to the specific field we desire.
General Example
sfdx force:source:retrieve -m CustomField:MyCustomObject.MyCustomField
Explanation
- CustomField - The type of Metadata we are importing. In this case, a custom field that we created in the environment.
- MyCustomObject - The name of the object we created in the environment.
- MyCustomField - The field we want to import into our project.
Example With an Object and Field
sfdx force:source:retrieve -m CustomField:Armor__c.Rating__c
Assuming the object "Armor" and the field "Rating" exist in our environment, running the code in the example will import the "Rating" field into our project.