Skip to content

Use Anonymous Apex Scratch in VS Code

Task guide

Open a scratch Apex file, run it locally, and read the generated debug log.

  • Open a small scratch editor.
  • Run the whole buffer.
  • Use the active local DB.

Before you start

  • VS Code has the bundled Glade extension installed; no particular theme or profile is required.
  • The project's Apex source version is eligible for Execute Anonymous (65.0, 66.0, or 67.0).
  • The active Glade local data environment is the one you want to write to.

Steps

1. Open the scratch buffer

Open an anonymous Apex scratch buffer or a small .apex scratch file.

VS Code showing an anonymous Apex scratch buffer

2. Run or debug the Apex

Use Cmd+Enter on macOS or run glade exec --debug-log - --project . <apex>. Select a smaller block when you want to run only part of the buffer.

Expected: Glade runs local anonymous Apex against the active DB and prints a Salesforce-style debug log.

VS Code showing an anonymous Apex debug log

Common wrong turn

If the command says no Salesforce DX project is open, open the project root folder, not a single .cls file.

Next

Glade is an independent project and is not affiliated with, sponsored by, or endorsed by Salesforce. Salesforce and Apex are trademarks of Salesforce, Inc. · Maintainer · Security · Releases · Apache-2.0