#debug

2025-05-14

Error Busters: Guide to Solving Flow and Apex Trigger Errors in Salesforce

Hey there, fellow Trailblazers! Ever hit a snag with a Flow or an Apex trigger and felt like you needed a magnifying glass and a detective hat? You’re not alone! Errors happen, but luckily, Salesforce gives us some fantastic tools and strategies to figure out what went wrong. Think of troubleshooting less like a chore and more like some fun detective work.

Last week I attended MidAtlantic Dreamin where I presented on this topic. You can download my slides using the link on the bottom of this page. But before that, let me give you an overview of the content.

Here are my tips for solving flow and Apex trigger errors in Salesforce.

Starting Your Detective Work: The Essential First Steps

When an error pops up, don’t panic! Take a deep breath and start with the basics:

  1. Read the Error Message Carefully:This might sound obvious, but error messages are your first clue! For Flows, check the error message at the top and bottom of any fault emails you receive – they can be super descriptive. For Apex, you’ll get unhandled exception emails; make sure to read these closely too. Sometimes the message itself tells you exactly what happened.
  2. Inspect Your Test Data: Make sure the data you’re using for testing is appropriate. If you’re working with Flows, try not to reuse old records. Why? They might have weird field value combinations due to recent changes in automation or validation rules. For Apex, your test classes should generate appropriate test data.
  3. Become a Debug Log Pro: The debug log is your absolute best friend! It shows you exactly what happened during the execution of your Flow or Apex trigger. For Flows, try reading the log like a book from top to bottom to trace the path. For Apex, the log shows variable values and exceptions. You can set up a detailed user trace for the user running the automation to capture all the gory details.
  4. Check Fault Emails (and Failed Flow Interviews): If a production Flow fails and doesn’t have a fault path (more on those later!), an administrator or the creator gets a fault email. This email is golden! It has a link directly to the failed interview, showing you a stop sign icon, and often highlights the failing element. You can also check the Paused and Failed Flow Interviews screen in Setup for details and debug log links. Apex failures send unhandled exception emails. Read those emails carefully.

Flow-Specific Super Skills

Flows have some unique debugging powers. Make sure you use them!

  • Debug As You Build: Don’t wait until your Flow is a giant spaghetti monster! Debug it in meaningful parts right after saving each section. This keeps the debug log manageable and helps you catch issues early.
  • Use the Flow Debugger Extensively: This built-in tool is fantastic! You can skip start conditions, run as a different user (great for checking permissions!), and inspect variable values at every step.
  • Look for Stop Signs: When debugging, if you see a stop sign, that means an error happened during that debug run. Also, make sure the path followed is highlighted all the way to the end for a successful execution.

  • Test Activated Flows in a Sandbox: Debugging is awesome, but the real test is when the Flow is activated and running in a sandbox environment. This simulates production better.
  • Understand Transaction Boundaries: Be aware that errors in one part of a screen Flow transaction might not roll back changes from a previous successful step unless you use a Roll Back Records element. This is especially important with screen Flows and data manipulation. Know that you may get a partial save and commit for collection operations, when using the fault path in a flow.
  • Reverting Versions: If an error started happening after a recent change, consider reverting to a previous working version. Sometimes, a Flow can even become corrupt and you might need to clone a working version or build a new one.
  • Scheduled Path Flow Testing: For these, debug each scheduled path separately. When initially testing, set the schedule to run one minute later for quick results. You can monitor pending actions in the Time-Based Workflow screen.

Apex Trigger Troubleshooting Tactics

Apex triggers require a slightly different approach:
  • Isolate the Trigger: If you have several triggers on the same object, try to figure out which one is causing the error.
  • Review Your Logic: Go through the code carefully, looking at conditions, loops, and DML operations to pinpoint the source of the error.
  • Consider a Trigger Handler Framework: If you have many triggers on an object, using a framework can help manage and orchestrate them, making isolation, testing and debugging easier.

Tips for Both Flows and Apex: The Universal Rules

These gems apply whether you’re building with clicks or code:
  • Master the Order of Execution: Salesforce has specific steps it follows when a record is saved. Understanding how Flows, Apex, Workflow Rules, and Process Builders interact is crucial. Knowing the order helps you find conflicts.
  • Respect Governor Limits: Salesforce sets limits on things like how many SOQL queries or DML operations you can do in a transaction. Going over these limits causes errors! A common mistake is doing operations inside loops. Flows and Apex even have some separate limits (e.g. scheduled jobs).

  • Simplify or Isolate Complex Automation: If your automation is huge and complicated, try breaking it down or isolating the specific part where you think the error is happening.
  • Check Permissions and Access: Does the user running the Flow or trigger have the right permissions for the objects and fields involved? Test running Flows as different users to check this.
  • Look at Related Automation: Sometimes, an error in your Flow or trigger is actually caused by a validation rule or another piece of automation running on the same object. Deactivate or examine related automation to see if they’re the culprits. Using Custom Metadata Type switches can help with temporarily disabling automation for testing (see Using Custom Metadata Types in Flows Without Get).
  • Search Online! If you get a weird error message, chances are someone else has seen it before! Search Salesforce forums, Stack Exchange, and other communities. Leverage AI LLM models.
  • Ask for Help: Don’t bash your head against the wall alone! Collaborate with other admins or developers. Sometimes a fresh pair of eyes is all you need. Join the Flownatic Slack Workspace.
If you experience frequent issues, consider setting up a logger like Nebula logger (Jonathan Gillespie – jongpie on GitHub). Troubleshooting might seem a bit daunting at first, but with these strategies, you’ll be zapping those errors like a pro! Just remember to be Sherlock Holmes, look for the little signs, and enjoy the process! Download my slideset from MidAtlantic Dreamin here. Happy Debugging! Explore related content: How to Set Up Automated Email Alerts in Salesforce Flow 15 Effective Salesforce Flow Debug Strategies Is Your Salesforce Flow Too Big?

#Apex #ApexTrigger #Debug #MidAtlanticDreamin #Salesforce #SalesforceAdmins #SalesforceDevelopers #SalesforceTutorials

Error Busters Guide to Solving Flow and Apex Trigger Errors in Salesforce blog image. A man is looking at his computer with a magnifying glass, and he is wearing detective clothes.User Trace Debug LogPaused and Failed Flow Interviews Screen
N-gated Hacker Newsngate
2025-05-07

🎩 "Behold the revelation: can actually errors! 🕵️‍♂️ Who knew?! Apparently, the entire was just waiting for this genius to grace their screens. 🤡"
qodo.ai/blog/java-unit-testing

Piotr Esden-Tempskiesden@chaos.social
2025-04-28

Continuing the assembly marathon. Today assembling Black Magic Probe V2.3 JTAG/SWD debugger and programmer. #manufacturing #electronics #jtag #debug #embedded

Piotr Esden-Tempskiesden@chaos.social
2025-04-27

Today assembling ARM Cortex debug to legacy 20pin JTAG adapters. Slowly getting on top of the production backlog. :) #manufacturing #electronics #jtag #debug #embedded

Martin Guay 👨‍💻🌈🎮📱🍁MartinGuay@mstdn.ca
2025-04-26

Cloudflare worker and Readablestreams. What a shit show. Finally got that working instead of generating "uncaught exceptions" with no information. #Cloudflare #Worker #Debug #Readablestream #Tech #IT

2025-04-25

Any high-follower (10-20k+) techy person interested in helping me debug a tool I made for viewing the distribution of your followers/accounts you follow?

data.stefanbohacek.dev/project

#fediverse #debug #HelpWanted #opensource

1. Arduino loop() function randomly crashes.
2. Add debug output to find where it crashes.
3. loop() function runs for hours without an issue.

#arduino #esp32 #debug

2025-04-15

Incomplete JSON Pretty Printer
"Format truncated or incomplete JSON into a readable structure."

2025-04-15

Learn how to work with #OneIdentity Active Roles #debug logs, that is reading them using #syslog_ng Agent for #Windows and forwarding them to a central syslog-ng server for long(er) term storage.

syslog-ng.com/community/b/blog

#LogManagement

Improving breakpoint management in openMSX. #openmsx #debug #msx #gamedev #emulation

New openMSX Breakpoint GUI interface options to save and load all breakpoints from the menu. Automatic saving and loading are there as well.
2025-04-13

laugh all you want but i did have to #debug a #binarysearch #algorithm writtin in #python tonight
also pruned a jacaranda tree
#sunday

2025-04-11

May have gone a bit over kill on the debug draw modes here...

#GameDev #Godot #CatmullClark #Debug #DrawModes #DebugdrawModes

Far too many different draw modes, many of them debug-only, for a simple shape Catmull-Clark subdivided twice...

Basic session management is almost ready. github.com/openMSX/openMSX/pul

Commands: save_breakpoints, save_watchpoints, save_conditions, load_breakpoints, load_watchpoints and load_conditions all available on openMSX console. #openmsx #z80 #debug #msx #gamedev #programming #debugging

2025-04-08
2025-04-08
2025-04-08

link and feel free to post again

Client Info

Server: https://mastodon.social
Version: 2025.04
Repository: https://github.com/cyevgeniy/lmst