Connect to an Org

Next, connect an org to your Code Builder environment. During the course of development, you use different types of orgs for different stages. For example, it's common to use a Developer sandbox or Developer Edition org during the development phase, and move to other sandbox types for integration, testing, and staging. Eventually, you deploy your changes to a production org. You can connect Code Builder to any of these orgs to deploy or retrieve metadata. For this quick start, you can use a Developer Edition org.

Code Builder runs in the cloud with a different IP address from your org and your computer. If your org has Trusted IP Ranges configured in Network Access in Setup, you can't connect to an org from Code Builder because the IP range for Code Builder can vary. See the Known Gaps and Issues doc on GitHub.

To connect to an org the first time you launch Code Builder:

  1. In your Code Builder environment, click Connect an Org to connect to the Salesforce org you want to work in.
  2. Enter the login URL or select the org you want to log into.
  3. Enter an alias for the org; for example, DE org.
  4. A code is displayed in a text box. Click Connect.
  5. Log in with the relevant username and password. Click Allow.
  6. Click Continue. You’re now connected to an org, and its name is visible in the status bar at the bottom of Code Builder.

You can change the org you’re connected to by clicking the name of the current org to bring up the Command Palette and run SFDX: Authorize an Org again.

After you authorize an org, we take care of future authorizations so you don't have to continually log in. Just click the org’s name and then choose the org from the list.

In the project explorer, right-click force-app/main/default/classes/HelloWorldApex.cls and click SFDX: Deploy Source to Org.

Your output panel shows this message:

  1. Select SFDX: Open Default Org to log into your org.
  2. From Setup, enter Apex in the Quick Find box, then select Apex Classes.
  3. Confirm that the HelloWorldApex class is now available in your org.

Congratulations on successfully creating and deploying an Apex class with Code Builder!

Working in the cloud has its advantages. However, unlike working on a desktop where you save your files to a local machine, you must either deploy your changes to your org or commit them to source control to save your work somewhere permanent. Work saved in your Code Builder environment will be there when you return, but Code Builder isn’t suited for permanent storage. We recommend saving your work before you close the Code Builder tab.

This quick start shows you how to create code and deploy it to an org. For information about using source control for saving your work and a more rigorous development lifecycle, see Salesforce Development Models.

We may delete your Code Builder environment if its been inactive for longer than 60 days.