Fix the Overwrite Apex Code Popup in Developer Console

You’re deep in the zone, finishing up a tricky fix, and you hit save only to be blocked by the Overwrite Apex Code popup. It’s one of those moments that can really ruin your flow. One minute you’re about to wrap up for the day, and the next, you’re wondering if you just accidentally wiped out a coworker’s work or if Salesforce is just being glitchy again.

What the Overwrite Apex Code warning actually means

The short answer? Your browser is out of sync with the server. When you open an Apex trigger or a class in the Developer Console, Salesforce loads that code into your local session. But if someone else saves a change to that same file while you still have it open, the version on the server is now “newer” than the one on your screen.

So, when you try to save, the console realizes the timestamps don’t match. It throws the Overwrite Apex Code prompt to stop you from blindly crushing whatever changes were just made. It’s a safety net, even if it feels like a nuisance at the time.

In my experience, most teams hit this because they’re mixing tools. If you have the same class open in the Developer Console and VS Code, you’re almost guaranteed to see this. Pick one tool and stick to it for that task.

Common reasons you’ll see the Overwrite Apex Code message

Look, we’ve all been there. You leave a tab open from yesterday, come back in the morning, and start typing. Here are the most likely reasons that window is popping up:

  • Concurrent Edits: A teammate is working on the same file in the same sandbox. It happens more than you’d think in busy projects.
  • Tool Mismatch: You saved a change via VS Code or a deployment tool, but you still have the old version sitting open in your browser tab.
  • Automated Updates: A CI/CD pipeline or an automated script pushed a metadata update to the org while you were looking at the code.

Now, if you’re using certain Salesforce Chrome extensions to help with your dev work, they can sometimes trigger these refreshes in the background too. It’s always worth checking who else is in the sandbox before you start a heavy coding session.

How to handle the Overwrite Apex Code prompt safely

So what should you do when it happens? Don’t just click “OK” out of habit. That’s a recipe for a bad afternoon. First, copy your current code and paste it into a notepad or a scratch file. You don’t want to lose your hard work if the refresh goes sideways.

Check the server version first

Before you click through that Overwrite Apex Code modal, try to see what actually changed. If you have the file open in VS Code, do a “Diff with Org” to see the line-by-line differences. If the changes on the server are important, you’ll need to merge them manually into your code before saving again.

When is it safe to just overwrite?

Here’s the thing: if you know for a fact that you were the last person to touch that code – maybe you just saved it two minutes ago in another window – then it’s usually fine. But if there’s any doubt at all, refresh the view. Close the tab in the Developer Console and re-open it. It’s better to spend sixty seconds merging code than two hours trying to figure out why a feature you just fixed is suddenly broken again.

Key Takeaways for Overwrite Apex Code

  • The prompt is there to prevent data loss, not just to annoy you.
  • Always keep a backup of your local changes before confirming an overwrite.
  • Avoid keeping the Developer Console open for days at a time without refreshing your tabs.
  • Shift toward source-driven development with Git to handle these conflicts properly.

At the end of the day, the Developer Console is a bit of a legacy tool. It’s great for quick anonymous blocks or a fast one-line fix, but for serious work, it lacks the conflict resolution we get in modern IDEs. If you find yourself constantly battling the Overwrite Apex Code popup, it might be time to move your workflow entirely into VS Code. It handles these “collision” scenarios much more gracefully and keeps your sanity intact.