Skip to main content

Execute Apex

Run anonymous Apex against a connected org and read the debug output - for one-off scripts, data fixes, and post-deploy steps.

Try it in Serpent

Execute Apex runs a block of anonymous Apex against a connected org and returns the debug output. It is the quick way to run a one-off script, a data fix, or a post-deployment step without leaving Serpent or opening the Developer Console.

Execute Apex flow: choose an org or scratch org and base branch, pick the Apex source (User Repo, Serpent, or Inline script), and select the Apex files to run

What you can use it for

  • Run a one-off data fix or backfill against a sandbox before a release.
  • Trigger a post-deployment step, such as scheduling a job or seeding a record.
  • Check behaviour quickly by running a snippet and reading the debug log.

Run it in Serpent

Execute Apex runs from a Work Item. Open a Work Item with the "Try it in Serpent" button above, then:

Work Item More actions menu with Execute Apex, alongside Deploy from Source, Retrieve Changes, and Execute Automation Flow
  1. Open Execute Apex

    On the Work Item, open More actions and choose Execute Apex.

  2. Pick the org

    Choose the connected org to run against. Run against a sandbox or scratch org first, not production.

  3. Add your Apex

    Paste or write the anonymous Apex you want to run.

  4. Run and read the output

    Run it, then read the returned debug output to confirm what happened.

Tracked like any action

Execute Apex is a Serpent action, so each run is recorded with its output and status. You can see it in the action history and follow up if something needs attention.