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
  • n

  • Verify installation is complete > sfdx -version
  • n

  • Install the Salesforce Extension Pack, inside vscode > extensions > Salesforce Extension Pack
  • n

  • Create sfdx project in vscoden
      n

    • press cmd+shift+p inside vscode
    • n

    n

      n

    • select SFDX: Create Project
    • n

    • Enter name and press enter
    • n

    • Search project-scratch-def.json file
    • n

    • Edit orgName
    • n

    n

  • n

  • Connect VS code to salesforce orgn
      n

    • press cmd+shift+p inside vscode
    • n

    • Type SFDX: Authorize an Org
    • n

    • Press enter (accept default URL link)
    • n

    • Enter alias as vscodeIntegration
    • n

    • Grant access, through login page for salesforce sandbox
    • n

    • Above vscode screenshot shows that integration is succesfull
    • n

    n

  • n

  • Create salesforce code in VS Coden
      n

    • Create apex classn
        n

      • Right click on force-app > classes and select apex class
      • n

      • Enter name of class say AccountService > press enter
      • n

      • 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

  • Deploy code to salesforce sandboxn
      n

    • Right click the classes folder and select deploy to org option
    • n

    n

  • n

  • Verify its deployed by checking in sandbox > setup > devloper console> file > open > classes > AccountService
  • n

  • 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
    • n

    • press cmd+shift+p inside vscode
    • n

    n

      n

    • select SFDX: Create Project with Manifest
    • n

    • select standard project template
    • n

    • Enter name and press enter 
    • n

    • Follow the above steps to connect to Org
    • n

    n

  • n

  • Retrieve code from source Orgn
      n

    • After org connection is successful 
    • n

    • Right click on package.xml file and retrieve from Org
    • n

    • 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

Was this article helpful?
YesNo

Similar Posts