ApexSensei

Blog

Your First Salesforce Developer Org: Practice Anonymous Apex for Real

By Firus Hanov · · 8 min read

Sign up for a Salesforce Developer org, run executeAnonymous, read USER_DEBUG, and pass ApexSensei's first org-run drill. Write Apex and Think in classes are free to Check and Run.

Your First Salesforce Developer Org: Practice Anonymous Apex for Real

A Salesforce Developer org is the cheapest honest place to learn Apex. It is a real org. It has real governor limits. It has Developer Console, debug logs, and executeAnonymous. You do not need a paid license to start.

Write Apex and Think in classes are free to Check and Run. The first useful move is still the same: get an org you control, then run one statement and read the log. This article is that first session — signup, anonymous Apex, USER_DEBUG, and the drills that match it.

What a Developer org actually is

Salesforce sells several sandboxes. A Developer Edition org is not a copy of a customer's production. It is a standalone environment with a smaller data cap, most platform features turned on, and a login on login.salesforce.com.

That is enough. You can insert Accounts, write classes, run tests, and hit the same 100-SOQL / 150-DML transaction limits you will meet at work. The data is fake. The platform behavior is not.

A Trailhead Playground is also a Developer org under the hood. A scratch org is a disposable Dev Hub child. Either works for anonymous Apex. ApexSensei grades against the Developer org you connect with OAuth, so pick one login you will keep for more than an afternoon.

Sign up at developer.salesforce.com/signup. Use an email you can confirm. Wait for the login email. Change the password. Then ignore Setup's 400 menu items until you can run one line of Apex.

Open Execute Anonymous

In Lightning, the Developer Console is still the fastest anonymous runner:

  1. Click the gear, then Developer Console.
  2. Choose Debug → Open Execute Anonymous Window.
  3. Paste a snippet. Check Open Log.
  4. Click Execute.

The Tooling API method behind that button is executeAnonymous. ApexSensei's org-run drills call the same API against your connected org. If a snippet compiles and runs in Developer Console, the same shape can grade on the site.

VS Code with Salesforce Extensions can run anonymous Apex too. The console is enough for night one.

Anonymous Apex is a scratch pad. The class is not saved. The log is the product.

Your first snippet should print one labeled line

Do not start with a trigger. Start with a value you can see.

String greeting = 'Hello, ApexSensei!';
System.debug('Greeting: ' + greeting);

After Execute, open the log. Filter to Debug Only if the file is noisy. You want a USER_DEBUG line:

USER_DEBUG|[2]|DEBUG|Greeting: Hello, ApexSensei!

That label matters. ApexSensei's first org-run drill, Hello, ApexSensei, grades the debug line, not a screenshot of the editor. If the comma, casing, or exclamation mark is wrong, the assertion fails. That is the point.

Apex strings use single quotes. Statements end with a semicolon. Concatenate with +. None of that is optional syntax you can "style" away.

What anonymous Apex will not do

Anonymous Apex compiles, runs, then throws the type away. You cannot define a reusable public class in that window and call it later. You cannot deploy a test class from it. You cannot persist a trigger.

You can DML. This inserts a real Account in your org:

Account row = new Account(Name = 'AS-Practice-' + Datetime.now().getTime());
insert row;
System.debug('Inserted: ' + row.Id);

That is useful. It is also how people fill a Developer org with junk. Tag names with a prefix you can query later, or wrap practice DML in a savepoint:

Savepoint sp = Database.setSavepoint();
Account row = new Account(Name = 'AS-Rollback-Demo');
insert row;
System.debug('Temp Id: ' + row.Id);
Database.rollback(sp);

ApexSensei anonymous drills that insert practice records typically rollback after the run. Developer Console will not do that for you unless you write it.

Use anonymous Apex to prove a statement. Use a real class when the behavior has to survive a refresh of the page.

Read the log like a grader

The debug log is a timeline, not a console.log dump. Interesting event types:

  • USER_DEBUG — your System.debug calls.
  • EXCEPTION_THROWN / FATAL_ERROR — the snippet died.
  • SOQL_EXECUTE_BEGIN — a query ran. Count them.
  • DML_BEGIN — a write ran. Count them too.
  • LIMIT_USAGE_FOR_NS — governor snapshot at the end of the request.

Turn on Apex Code and Database at DEBUG in Debug → Change Log Levels if those lines are missing. Leave Profiling and Callouts at INFO until you need them. A maxed-out log is unreadable and hits the log-size cap.

When a drill says "print Basic count: 1", it means that exact USER_DEBUG string. Extra spaces fail. A JSON blob you thought was prettier fails. Match the label, then match the value.

Connect the org to ApexSensei

Sign in on ApexSensei, open a drill that requires Salesforce, and complete the OAuth prompt. Production logins are blocked in product copy. Use the Developer org. Approve the Connected App. The site stores an encrypted refresh token so later runs do not bounce you through login every time.

Then run something tiny. Comments that survive review is the pattern-check opener — it grades in the app, no org required. The next drill, Hello, ApexSensei, is the first anonymous run. If that passes, your connection, Tooling API, and debug log path all work.

The rest of Write Apex stays in that anonymous shape: dates, collections, maps. Think in classes still executes snippets in the org; you are writing class-shaped code that the runner wraps. Triggers and tests switch to Metadata deploy plus runTests. You do not need that on night one.

Write Apex and Think in classes are free to Check and Run. Every other drill is free to read, and Apex Path unlocks running them for $19/month after a 7-day trial. The details are on the pricing page.

A 20-minute practice loop

Use this once, then throw it away:

  1. Execute the greeting snippet. Confirm one USER_DEBUG line.
  2. Change the string. Confirm the log changed. That is your feedback loop.
  3. Insert one tagged Account. Query it back by Id. Print the Name.
  4. Rollback. Query again. Confirm the row is gone.
  5. Switch to ApexSensei and pass Hello, ApexSensei.

The query step looks like this:

Account seeded = new Account(Name = 'AS-Q-' + UserInfo.getUserId());
insert seeded;
List<Account> matches = [
    SELECT Id, Name
    FROM Account
    WHERE Id = :seeded.Id
];
System.debug('Count: ' + matches.size());
System.debug('Name: ' + matches[0].Name);

Bind the Id. Do not query WHERE Name LIKE '%AS-%' and hope. Your org will collect other tagged rows. The Query one Account drill is this pattern with stricter labels. Save it for after Write Apex; the habit belongs in week one anyway.

Common first-night failures

Double quotes. Apex is not JavaScript. "Hello" does not compile.

Missing semicolon. The error points at the next line. Read one line above the caret.

No USER_DEBUG. You executed without System.debug, or log levels hid it. Open Log, filter Debug Only, raise Apex Code to DEBUG.

OAuth against production. Do not practice in a customer org. Developer Edition is the point.

Anonymous class definitions. Put learning classes in Setup → Apex Classes, or let ApexSensei's deploy_test drills deploy them. The anonymous window is for statements.

Leaving inserted rows. Prefix practice data. Delete by prefix at the end of the week, or rollback as you go.

When to leave anonymous Apex behind

Move on when you need any of these:

  • A method another snippet should call.
  • A test that must fail when behavior changes.
  • A trigger, queueable, or batch that Salesforce has to persist.

That is the rest of the path: classes, SOQL, DML, then tests that are allowed to fail, then triggers. Anonymous Apex stays useful as a scratch pad — a bind variable check, a one-off query, a governor snapshot — even after you can deploy.

If you want a longer session tonight, finish Write Apex through maps. If you only have twenty minutes, get the org, print one labeled line, and stop. The org will still be there tomorrow.

Practice on the path

Start at /learn/write-apex/hello-apexsensei. When SOQL is next, skip the textbook chapter and run Bind an Account name so the colon-bind is muscle memory. When you are ready to prove behavior instead of printing it, read Write Apex Tests That Actually Fail Before You Deploy and open Assert service outcomes.

The playground on ApexSensei is the same editor without a sequenced drill. Use it when you want to try a snippet before it lives on the path. It still needs the connected org for anonymous runs. It will not replace Developer Console when you are debugging a log level, but it will replace a pile of untitled notepad files.

A Developer org is not a tutorial. It is the same runtime you will break in production, with records you are allowed to break. Run the snippet. Read the log. Then run it again.

Practice Apex free on ApexSensei