Loading

Create a Salesforce DX Project in VS Code and Search for Hard-Coded References

Publiceringsdatum: Jun 2, 2026
Beskrivning

The Salesforce Extension Pack for Visual Studio Code (VS Code) is the recommended integrated development environment (IDE) for developing on the Salesforce platform. It replaces the deprecated Force.com Plugin for Eclipse. VS Code with the Salesforce Extension Pack (SFDX) includes tools for code editing, build automation, debugging, and intelligent code completion.
This article explains how to create a new Salesforce DX project in VS Code, authorize an org, retrieve metadata using a package.xml manifest, and then search the retrieved codebase for hard-coded references — such as org-specific IDs, hardcoded URLs, or object names that should be dynamically resolved.

Lösning

Prerequisites

Before following these steps, ensure you have installed Visual Studio Code and the Salesforce Extension Pack. See the Trailhead Quickstart guide linked in Additional Resources.

Creating a Salesforce DX Project in Visual Studio Code

Follow these steps to create a Salesforce DX project and retrieve metadata from your org:

  1. Open the VS Code editor. From the Command Palette (Cmd+Shift+P on Mac, Ctrl+Shift+P on Windows), run SFDX: Create Project with Manifest.
  2. Run SFDX: Authorize an Org and select a login URL — for example, Production.
  3. After providing an org alias, a browser window opens. Allow access, log in to your org, and return to the VS Code window. The Org Picker shows the alias you provided.
  4. When you run SFDX: Create Project with Manifest, a package.xml file is created. Add the metadata types you want to retrieve to this file. See Sample package.xml Manifest Files in the Metadata API Developer Guide (linked in Additional Resources).
  5. In the VS Code Explorer or editor, right-click the manifest file and select SFDX: Retrieve Source in Manifest from Org. This retrieves all components from your authorized org based on what is defined in package.xml.

Searching for Hard-Coded References in the Project

Once metadata is retrieved, search for hard-coded references (such as org IDs, hardcoded URLs, or object names) using the built-in VS Code search:

  1. Press Cmd + Shift + F (Mac) or Ctrl + Shift + F (Windows) to open the global search.
  2. Enter the hard-coded value you want to find — for example, a specific org ID, URL, or API name.
  3. VS Code searches all files in the project and returns matching results with file paths and line numbers.

Considerations

  • To work with scratch orgs, use force:source:pull instead of the manifest-based retrieve approach described above.
  • You can also use the Org Browser in VS Code to browse and retrieve metadata without a package.xml file. See the Org Browser documentation in Additional Resources.
  • Non-scratch orgs use the manifest-based approach des
Knowledge-artikelnummer

000381316

 
Laddar
Salesforce Help | Article