CodeScience tech webinars deliver helpful advice for Salesforce developers direct from members of our industry-leading engineering teams. In our latest tech webinar, CodeScience Technical Architect, Rob Davis, takes a deep dive into BatchApexErrorEvent. This error handling tool, newly available with the Salesforce Spring ‘21 release, makes it easier for ISVs to diagnose and debug batch processing errors. Rob explains and demonstrates how ISVs can use this new tool in tandem with other error handling methods to make their managed packages more resilient.

 

Watch the full webinar today!

Why do errors occur?

Rob starts off by looking at some of the reasons errors occur in the first place. Developers aren’t perfect, Rob admits, “and sometimes there are coding mistakes.”

Aside from the occasional developer error, there are a host of things subscribers can do to cause errors to occur, from misconfiguring applications, such as missing necessary permissions or supplying incorrect credentials, to building logic, automation, or validations on top of the code that cause the app not to perform the way it’s expected to.

There’s no shortage of ways for errors to creep into apps, even beyond the reasons Rob notes. “Sometimes errors just happen,” he acknowledges, “and it’s hard to know why.” So, how can ISVs handle unexpected errors with unknown causes?

Reactive vs. proactive error handling

Reactive error handling is the most basic — but certainly not the best — way to address errors. It’s not so much an error handling method as it is a reaction to subscribers realizing a particular functionality isn’t working, and reaching out to customer support to inform the ISV.

batchapex-reactive

One issue with this approach is that customer support may have limited visibility to try to diagnose and fix the issue. Support staff may have only the information the subscriber is able to gather and provide, and may need to get access to their org to debug the issue because debug logs are not visible in subscriber orgs by default. It’s very difficult to fix errors, let alone fix them quickly and cost-effectively, without complete visibility.

Perhaps the biggest issue with reactive error handling is its potential to erode trust between ISVs and their customers. If customers are regularly running into situations where the functionality of an app doesn’t perform properly, their confidence in both the product and the ISV will quickly be lost. “Ultimately this is a time-consuming, costly process that can lead to a loss of trust,” Rob warns. “It’s hard to catch issues this way and when you do catch them, it’s often too late to really help, and you don’t know if other subscribers are running into something similar.”

Proactive error handling with BatchApexErrorEvent

A much better approach to error handling is to be proactive, meaning “you attempt to catch errors that you can anticipate,” Rob explains, along with taking steps to try to catch potential unexpected errors. Unfortunately, there have not been a whole lot of tools available for proactive error handling.

Enter BatchApexErrorEvent!

batchapex-overview

Newly available in the Spring ‘21 release, BatchApexErrorEvent allows ISVs to proactively monitor the health of batch jobs and take necessary corrective action on any errors found. It includes information such as job id, error type, and record IDs being processed, and is triggered on any batch error, including “uncatchable” errors, such as limit exceptions. “There’s no other way to handle those types of errors,” Rob notes. “Usually they just happen and you don’t even have the ability to log any information about them, so that’s a unique benefit to using this [tool].”

BatchApexErrorEvent provides much more information and visibility than one would have with the reactive error handling approach mentioned above. It does, however, have its limitations, and Rob provides a comprehensive review of these.

Setting Up and Using BatchApexErrorEvent

Rob then walks us through a comprehensive demo of how to use BatchApexErrorEvent triggers in a managed package. We’ve shared the basic setup here, but you’ll need to register to see the full demo in action.

batchapex-setup

To wrap up, Rob offers a high-level summary on the role BatchApexErrorEvent should play within an ISV’s larger error handling toolkit, and various options for how to handle the information it provides. Used in tandem with other available error handling tools, BatchApexErrorEvent can increase the resiliency of your solution and make debugging issues easier.

As Rob notes, “This all leads to increased trust with your customers and decreased reliance on customer support for your organization, so you can focus on hooking up features and selling to customers!”

To learn more, watch the webinar today!


Do more with your Salesforce product than you ever thought possible. At CodeScience, we enable ISVs to thrive on the AppExchange. Learn how we can help your business.