Skip to main content
Free Agentforce workshops and AI Certifications: Learn more. Terms and conditions apply.

Launch Code Builder

Learning Objectives

After completing this unit, you’ll be able to:

  • Access the Code Builder app in your org.
  • Connect to your org with Code Builder.
  • Execute a SOQL query.

Open the Code Builder App

Code Builder is installed and the CodeBuilderGroup permission has been granted. Let’s access the Code Builder Dashboard and start it up.

  1. From App Launcher (“”), find and select Code Builder.
    Code Builder app page with the Launch button.
  2. Click Launch.
    The first time you launch Code Builder it runs through a setup process that takes some time. You’ll see the message: “Code Builder is loading…” There may be a couple of alerts that you can disregard.

Code Builder opens with a new Salesforce DX project already initiated. The file structure is displayed in the Explorer next to the Activity Bar. Currently none of your org metadata or files are loaded into the project. We get to that in a bit. Code Builder displaying the project file structure and Activity Bar.

Get to Know the Activity Bar

The menu consists of eight primary options.

Option

Description

Explorer

“”

Displays the directory structure and all of the files that you've pulled from the authorized org into your local project.

Search

“”

Allows you to search for things in the project. To search for items in your authorized org, you need to download them first with the Org Browser.

Source Control

“”

Maintains a list of updates to files in your project. This is usually connected with GitHub.

Run and Debug

“”

Allows you to run code, set breakpoints, watch variable values, and view the call stack.

Extensions

“”

Displays all the extensions you can add to Code Builder to enhance your coding. The primary Salesforce extensions come preloaded in Code Builder.

Testing

“”

Allows you to run Apex and LWC tests and monitor results.

Code Builder

“”

Provides access to the Code Builder Resource Panel with quick links, quick start guides, video, and links to Trailhead and help documentation.

Org Browser

“”

Links to all the metadata and files on the authorized org. From the Org Browser you can download the metadata you want to work on.

Org Differences

“”

Shows conflicts or differences between orgs if Detect Conflicts at Sync is enabled.

Authorize Your Org

In order to view metadata or files from your org, you need to authorize Code Builder to access the org using your credentials. You can authorize any org (production, sandbox, or scratch) using your username and password.

  1. If the home page is showing, click Connect an Org.
    If not, just press Ctrl+Shift+P (Windows) or Cmd+Shift+P (macOS) to open the command palette. Enter SFDX and select SFDX: Authorize an Org.
  2. For org type, select Production so you can connect to a Trailhead Playground.
    A list of options for authorizing different orgs: Project Default, Production, Sandbox, and Custom.
  3. For alias, enter CBTrailhead and press Return (MacOS) or Enter (Windows).
    You can have multiple authorizations so create distinctive aliases to easily set them apart.
    A special connection screen just for Code Builder opens with a code prepopulated for you.
    The Enter Code window displays the Code field pre-populated with a code, a Cancel button, and a Connect button.
  4. Click Connect.
  5. Log in with your username and password for the org you are authorizing.
  6. Click Allow.
  7. Click Continue.
    You’re now connected to an org, and its name is visible in the status bar at the bottom of the Code Builder window.
    The bar at the bottom of the Code Builder window shows CBTrailhead connected.

View Org MetaData

All right! You’re connected to your org. Now let’s get some metadata and files from the org into your Code Builder DX project to work with.

  1. In the Activity Bar, select the Org Browser (“”).
  2. At the top of the org browser panel, click SFDX Refresh Types (“”).Code Builder’s org browser displays a list of CBTrailhead metadata from the connected org.
  3. Scroll down and select Custom Objects.
  4. Select Retrieve Source from Org (“”) for Account. Code Builder’s org browser with Custom Objects open showing the Account object.

The metadata files are now in your Code Builder project. Let’s go take a look at them.

  1. Select Explorer (“”).
  2. Select force-app.
    Code Builder Explorer showing the force-app/main/default folder open to display its contents including the classes folder.
  3. Select objects.
    The force-app/main/default/objects/Account folder shows all the metadata files for the Account object. Here are the files you retrieved! But wait, there are a lot of files just for Account. Yep, each object has metadata files for all of its attributes. You can view a file to see each of its fields, listViews, and even its main Account.object-meta.xml file.

Now you know how to view and retrieve metadata and files from an authorized org. But what about the data? SOQL Builder is an awesome tool for looking at the org records.

View Records with SOQL Builder

SOQL stands for Salesforce Object Query Language. It’s a simple command language that facilitates record retrieval from a Salesforce org. There’s a lot you can do with it. Check out the SOQL for Admins Trailhead badge for more details on how you can use SOQL. But for now, let’s just explore some records in your org.

  1. Press Ctrl+Shift+P (Windows) or Cmd+Shift+P (macOS) to open the command palette.
  2. Enter SOQL and select SFDX: Create Query in SOQL Builder.
  3. In the From field, enter cont and select Contact.
    “”.
  4. For Fields enter id and select Id.
  5. Enter another field: Name.
    When values are selected for From and Fields, SOQL Builder displays the actual SOQL Query: SELECT Id, Name FROM Contact.Watch the SOQL Query appear based on the field values you select.
  6. Click Run Query to see the results.
    SOQL Builder shows the query and the Id and Name of each record returned by running the query.
  7. Close SOQL Builder and click Save to save the query or Don’t Save to discard it.

There’s a lot you can do with SOQL Builder. Be sure to check out the Developers SOQL Builder page to get more insight into the tool and your records.

Now that you have an easy way to set up and use Code Builder, go forth and empower your users to tackle some code, or dig in yourself to experience all the amazing ways you can view your records and connected records without limitations. Find more on this in the Resources.

Resources

Comparta sus comentarios sobre Trailhead en la Ayuda de Salesforce.

Nos encantaría conocer su experiencia con Trailhead. Ahora puede acceder al nuevo formulario de comentarios cuando quiera desde el sitio de la Ayuda de Salesforce.

Más información Continuar para compartir comentarios