Search Here

Setting up a Salesforce project


 To begin Salesforce development, we need to create a Salesforce project in Visual Studio Code.

      1. Open Command Palette (Ctrl + Shift + P) or under View -> Command Palette.
      2. You now have two options of creating a project:
        • SFDX: Create Project | For developing using scratch orgs where deploys as a single package.
        • SFDX: Create Project with Manifest | Allows for downloading and deploying all code and metadata directly to Salesforce org.
      3. We will use SFDX: Create Project with Manifest so we can develop directly with the Salesforce org.
      4. Choose Standard Project.
      5. Enter a name for your project.
      6. Choose the location in your file system to save your project in.
      7. The project will be created. Here are some notable files and folders:
      8. force-app/main/default
      9. This will be where your source code and metadata for your Salesforce org will be located. (There won’t be any files in the folders for now).
      10. sfdx-project.json
      11. This will be your project configuration where you can add or change location of where your source code will be saved.
      12. manifest/package.xml
      13. This will be used to retrieve source code and metadata.
      14. Now we have project set up, we need to connect to a Salesforce org.
      15. Open Command Palette and enter SFDX: Set a Default Org
      16. Select SFDX: Authorize an Org
      17. Select the login URL for your Salesforce org. We will use Sandbox.
      18. Enter an alias for your org. Press Enter key and browser will open where you can login to your Salesforce org.
      19. Login to your Salesforce org. (Note: there will be a prompt asking for Salesforce CLI access, allow this to continue).
      20. Once logged in, go back to Visual Studio Code and you should see a “Successfully authorized” message and you may close the browser.
      21. Notice that your Org alias name now appears on the bottom bar of Visual Studio Code. You will also see the alias when you run SFDC: Set a Default Org, this allows you to freely swap between different orgs.

Now you have integrated your Salesforce Org with your Salesforce project.

Retrieving/Deploying source code and metadata

Now that you have integrated your Salesforce org with the project. You can download the source code and metadata. Open up Command Palette again and run SFDX: Retrieve Source in Manifest from Org. This will download all the metadata from your Salesforce org. The contents of the metadata to retrieve is defined in the manifest/package.xml under your project folder. You can modify the package.xml to your liking.






Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.