top of page
Writer's pictureA. Vishwakarma

FIND UNCAUGHT EXCEPTIONS OF TRIGGERS IN EVENT LOG FILES


Salesforce's Spring '24 release comes with a significant enhancement in the platform event trigger functionality. The update provides log file generation data, which captures uncaught exceptions as part of the log data. Previously, developers had to rely on analyzing log files based on logic changes to identify solutions when encountering an exception during the execution of an Apex trigger on platform event. However, with the latest update, Salesforce now specifically categorizes uncaught exceptions under the 'ApexUnexceptedException' event type in the log files. This improvement makes it easier for developers to identify the type of uncaught exception directly from the log files, leading to a more streamlined and comprehensive approach to troubleshooting.

I recommend reading through the insights shared in this blog post to better understand this new capability and learn the appropriate methods for addressing uncaught exceptions.


What is a Platform Event trigger?

A trigger on a platform event in Salesforce is like a special kind of trigger that reacts when certain events are published. Think of a platform event as a message that represents important things happening in your organization. These events help different parts of your Salesforce setup or even different Salesforce organizations talk to each other by sharing updates or changes. So, a platform event trigger is a tool tailor-made to handle and respond to these special messages, ensuring your Salesforce system communicates effectively in real time.


Event Log Files

In Salesforce, event log files are records that capture information about different types of events and activities occurring within the platform. These logs provide details about user activities, system events, and changes made to the Salesforce organization. Event log files are useful for monitoring and troubleshooting purposes, as they can help identify issues and analyze trends to improve the performance of the system.

 

Event Monitoring

Salesforce event monitoring is a robust tool that allows administrators to monitor user activity within their Salesforce organization. It provides comprehensive information about user actions, such as logins, logouts, and record modifications. This way, event monitoring helps organizations ensure data security and regulatory compliance while gaining valuable insights into user behavior.


Types of events

There are event types that can be useful for capturing various activities within the system in the above use case scenario.

 

Here are some standard event types that may be raised and logged:


  • Login Events: Captures user login activities, including successful logins and failed login attempts.

  • Platform Events: General event type for capturing a variety of platform-level activities and changes.

  • Logout Events: Records user logout activities.

  • API Events: Captures API usage, providing insights into how external applications are interacting with Salesforce.

  • Apex Execution Events: Records information about the execution of Apex code, including triggers and classes.

  • ReportEvent: Captures events related to running reports. DashboardEvent: Records events related to dashboard interactions.

  • Field History Tracking Events: Provides details about changes to tracked fields on records.

  • Metadata Changes: MetadataChangeEvent: Captures events related to changes in metadata, such as modifications to custom objects or fields.

  • User Provisioning Events: Records events related to user provisioning and de-provisioning.

  • Content Distribution Events: Captures events related to the distribution of Salesforce Content.

  • Lightning Page Events: LightningPageViewEvent Records events related to the viewing of Lightning Pages. There are many more types of a total of 63 events in Salesforce, from every event that occurs while running any event trigger. The event types you can access and how long the files remain available depends on your Salesforce edition.Developer Edition organizations have free access to all log types with 1-day data retention.Enterprise, Unlimited, and Performance Edition organizations have free access to the insecure external assets, login, logout, and total API usage event log files with 1-day data retention. For an extra cost, you can access all log file types with 30-day data retention.

Steps to see the log files

  • Open the Developer console.

  • Navigate to Files then open.









  • Select Entity Type - Object and Filter - ‘EventLogFile’ open.

  • Select fields of data you want to see in the Log

  • Click the Query button twice, it will generate a SQL query

  • Then click execute and it will open the EventLogFile.












Logs :


Event types                          Format for download                           Interval          

                                                                 Text/CSV                                     Daily/Hourly


Apex Unexpected Exception Event Type

The Apex Unexpected Exception event type captures information about unexpected exceptions in Apex code execution. This event type is available in the EventLogFile object in API version 45.0 and later.

The field that shows the behavior is through the workbench and ELF Browser

 

Workbench: REST Explorer

  • By using this login as the sandbox

  •  Then copy the Log File URL  from the developer console

  • Paste the URL in the workbench and select GET.

  • Log Data with all the event type


Event Log Files Browser

Log Files will only be available for download if an event occurred before 24 hours and if the event is occurring then you will have to wait for 24 hours for download.

 

Step to open ELF Browser

  • Open the ELF Browser application by clicking this link:   

  • Click Production Login.

  • Set the Start Date.

  • Select an event type for your search, or leave the event type set to All.

  • Click Apply. As shown in the below image.

  • Here you can see the event types :

















  • Log files with different types of events:


Conclusion

According to this blog, this release provides detailed log file generation data that makes it easier to identify uncaught exceptions. This feature streamlines troubleshooting and enhances customer engagement analytics. The blog also highlights user-friendly tools like Workbench and Event Log Files Browser that enable efficient data extraction and analysis. Moreover, the author encourages continuous learning and adaptation to fully leverage Salesforce's monitoring capabilities.

 

References


Blog Credit:

A. Vishwakarma

Salesforce Developer

   Avenoir Technologies Pvt. Ltd.

  Reach us: team@avenoir.ai



 

Are you in need of Salesforce Developers?

Reach Us Now!




 

Opmerkingen


bottom of page