How to Downloading Source to VS Code?

How to Downloading Source to VS Code?

On March 28, 2025, Posted by , In Salesforce Technical Questions, With Comments Off on How to Downloading Source to VS Code?
How to Downloading Source to VS Code

Question:

I am new to Salesforce and trying to retrieve source code from my scratch org into VS Code. I used the Salesforce CLI (sf) to create a new project and then created some custom objects in my scratch org. Now, I am trying to download the source using the following command:

sf project retrieve start --source-dir source/formulaforce/ --target-org myDevOrg

However, nothing is being retrieved, and I get a message saying “Nothing retrieved.” What am I doing wrong? How can I correctly pull my source code into VS Code?

Answer:

The issue is likely due to an incorrect source path or missing metadata in your project’s package configuration. Here are some possible solutions:

Boost your Salesforce career with CRS Info Solutions expert-led  Salesforce training, hands-on projects, and a free demo—perfect for beginners and professionals!!!

1. Verify the Source Path:

Ensure that the directory source/formulaforce/ actually exists and contains metadata. You can try retrieving all metadata instead:

sf project retrieve start --manifest manifest/package.xml --target-org myDevOrg

If you haven’t generated a package.xml, you can create one by running:

sf project generate manifest --type=All

2. Check Your Project Configuration:

Ensure your sfdx-project.json file is correctly set up. It should contain the correct path and packageDirectories that match your metadata location.

3. Retrieve by Metadata Type:

If you are looking for specific metadata, try retrieving it explicitly:

sf project retrieve start --metadata CustomObject --target-org myDevOrg

Replace CustomObject with the metadata type you need (e.g., ApexClass, LightningComponentBundle).

4. Check Org Connection:

Make sure your scratch org is properly authenticated and set as the default. Run:

sf org list

If your scratch org is not listed or expired, re-authenticate:

sf org login web --set-default-dev-hub

Or, if the scratch org is missing, create a new one:

sf org create scratch --definition-file config/project-scratch-def.json --set-default

5. Try Retrieving the Entire Project:

If the issue persists, try pulling all metadata without specifying a directory:

sf project retrieve start --target-org myDevOrg

If none of these solutions work, check the CLI logs using sf --verbose to see if any errors provide more insight.

Unlock Your Future with Salesforce Training in Chicago

Transform your career with our premier Salesforce training in Chicago, designed to fast-track your professional growth. Whether you’re a beginner or an experienced professional, our comprehensive course offers expert-level instruction in Salesforce CRM, hands-on projects, and guidance to help you earn certifications like Salesforce Administrator and Developer.

Our Salesforce training focuses on industry-relevant skills, with personalized mentorship, detailed course materials, and continuous support throughout certification and interview prep. Whether you’re starting fresh or looking to enhance your expertise, our seasoned instructors are committed to helping you succeed in a competitive job market.

Take the first step towards an exciting Salesforce career—join our free demo session today!!!

Comments are closed.