How to Use Salesforce Metadata API Using Visual Studio Code

How to Use Salesforce Metadata API Using Visual Studio Code

The Salesforce Metadata API helps you to move this metadata between orgs during the development process. It doesn’t work with the business data itself. It lets you deploy, retrieve, create, update, or delete your org’s configuration information in two ways:

  • Using deploy and retrieve calls — These calls are directly implemented in the API and are designed to overwrite the metadata in their destination. They move metadata to or from your org according to a manifest file that lists which metadata is to be acted upon. Often, these are used to move the entire set of metadata into or out of an org such as moving a set of changes to your production environment.
  • Using push and pull commands — These commands are abstractions built on deploy and retrieve that use a secondary change tracking feature (or source tracking). They deal strictly with changed metadata and will report conflicts instead of overwriting. These are helpful to developers as they build new features.
How to Use Salesforce Metadata API Using Visual Studio Code 2

  • The start of the development process would begin with creating the necessary sandboxes to do the work that you need to do. Sandboxes are clones of your production org and don’t require the Metadata API to be generated.
  • You decide to bring down all of the changes and configurations into your local project. You will make use of retrieve for this purpose as surfaced through the Salesforce CLI force:source:retrieve command.
> sfdx force:source:retrieve --sourcepath src --targetusername dev-sandbox
  • The new feature is going to require some new fields on existing objects. After making those changes in the org, you use pull to retrieve only the changes you made locally to your project via the force:source:pull command.
> sfdx force:source:pull --targetusername dev-sandbox
  • Your work also entails changes to some existing Lightning Web Components and Apex classes. You make those changes locally and want to see them work in your org. You can use the push command through force:source:push. Just like with pull, only the changes that you made are moved to your sandbox.
> sfdx force:source:push --targetusername dev-sandbox
  • After your isolated testing is satisfactory, you definitely want to test the feature in various integration environments, such as developer, developer pro, partial sandboxes, or full sandboxes. You can use deploy through the force:source:deploy command to move the metadata to these upstream sandboxes for integration, UAT, and end-user training.
> sfdx force:source:deploy --targetusername test-sandbox --sourcepath src
  • After completion, you are ready to use the Metadata API to move your changes to production.

Follow Us

Posted By : Sudeer Kamat Date :

view_module Related

  • Transfer Ownership of Lightning Dashboards (Beta) In #SalesforceWinter24ReleaseTransfer Ownership of Lightning Dashboards (Beta) In #SalesforceWinter24Release
  • Use Filters to Find Record-Triggered Flows Quickly In #SalesforceWinter24ReleaseUse Filters to Find Record-Triggered Flows Quickly In #SalesforceWinter24Release
  • Iterate Within For Loops More Easily with Iterable In #SalesforceWinter24ReleaseIterate Within For Loops More Easily with Iterable In #SalesforceWinter24Release
  • Meet RecordAction: The Unsung Hero of Salesforce's Actions & RecommendationsMeet RecordAction: The Unsung Hero of Salesforce's Actions & Recommendations
  • Query All Files Permission To Retrieve ContentDocumentLink Object In #SalesforceWinter24ReleaseQuery All Files Permission To Retrieve ContentDocumentLink Object In #SalesforceWinter24Release

label Labels

Comments 0