How to use visual studio code for Salesforce? – User friendly Tech help
n
Lets learn how to create Salesforce project in visual studio code editor
n
n
- n
- Install sfdx-cli on your pc by typing command in terminal > npm install -g sfdx-cli
- Verify installation is complete > sfdx -version
- Install the Salesforce Extension Pack, inside vscode > extensions > Salesforce Extension Pack
- Create sfdx project in vscoden
- n
- press cmd+shift+p inside vscode
n
n
- n
- select SFDX: Create Project
- Enter name and press enter
- Search project-scratch-def.json file
- Edit orgName
n
n
n
n
n
- Connect VS code to salesforce orgn
- n
- press cmd+shift+p inside vscode
- Type
SFDX: Authorize an Org
- Press enter (accept default URL link)
- Enter alias as vscodeIntegration
- Grant access, through login page for salesforce sandbox
- Above vscode screenshot shows that integration is succesfull
n
n
n
n
n
n
n
- Create salesforce code in VS Coden
- n
- Create apex classn
- n
- Right click on force-app > classes and select apex class
- Enter name of class say AccountService > press enter
- Replace newly created .cls code withn
public with sharing class AccountService { public static List AccountService() { List acct = [SELECT Name FROM Account Limit 4]; return acct; } }
n
n
n
n
n
n
- Create apex classn
- Deploy code to salesforce sandboxn
- n
- Right click the classes folder and select deploy to org option
n
n
- Verify its deployed by checking in sandbox > setup > devloper console> file > open > classes > AccountService
- Create sfdx project in vscode with Manifest Settings n
- n
- Advantage, this gives better control what all the files that you want to retrieve from Org, which is managed by manifest.xml
- press cmd+shift+p inside vscode
n
n
n
- n
- select SFDX: Create Project with Manifest
- select standard project template
- Enter name and press enter
- Follow the above steps to connect to Org
n
n
n
n
n
- Retrieve code from source Orgn
- n
- After org connection is successful
- Right click on package.xml file and retrieve from Org
- Below command can also be used to retrieve from Org, in terminal of VS Code > sfdx force:source:retrieve –metadata ApexClass:classname
n
n
n
n
n
n
n
n
n
n
n
n
n
n