Friday, January 18, 2019

Setting Up VS Code with Salesforce

These are step by step instructions to get VS Code working with Salesforce.


  1. Go to your Sandbox, under Setup search for Dev Hub.  Enable Dev Hub and GA.  This will allow you to create scratch orgs.
  2. Install the Salesforce CLI which will allow you to push and pull code and run tests:   https://developer.salesforce.com/tools/sfdxcli
  3. Install VS Code which is now the standard for editing code for Salesforce:  https://code.visualstudio.com/download
  4. Install Java if you do not have it installed yet.  The Salesforce Extension Pack requires it.  https://www.java.com/en/download/
  5. Install the Salesforce Extension Pack.  In VS Code, click the extensions icon and search for Salesforce Extension Pack.
  6. Install Lightning Web Components extension in VS Code
If your Salesforce code is in your org and not in source control then you are in Classic Development and not Salesforce DX.  

Classic Development Mode (directly interact with an Org)



* After creating the project, create these folders under the default folder before doing a Retrieve Source From Org:  

  • classes
  • objects

Salesforce DX Mode (your source is in GitHub or Bitbucket)

Example of cloning a repository, creating a scratch org and pushing the code

git clone https://github.com/dreamhouseapp/dreamhouse-sfdx
cd dreamhouse-sfdx
sfdx force:config:set defaultdevhubusername=your@username.com
sfdx force:org:create -a dreamhouse -s -f config\project-scratch-def.json -d 7
sfdx force:source:push
sfdx force:user:permset:assign -n dreamhouse
sfdx force:org:open -p /lightning/page/home

No comments:

Post a Comment