Home Salesforce Efficient Ways to Debug Salesforce Platform Events

Efficient Ways to Debug Salesforce Platform Events

by Dhanik Lal Sahni
Debug Salesforce Platform Events

Salesforce Platform Events are a component of Salesforce’s event-driven architecture, enabling developers to deliver secure, scalable, and customizable notifications within Salesforce or between Salesforce and external systems. These events allow an application to respond to Salesforce events, making integrating different systems and creating responsive, modern applications easier. We can publish and subscribe to platform events in Flow and Apex. Sometimes we need to debug platform events to identify if it is being published or subscribed properly. Debugging Salesforce Platform Events consists of several steps that focus on both the event configuration and the processes or triggers with which they are intended to interact. This blog will provide the top 10 techniques to Debug Salesforce Platform Events.

1. Verify Platform Event Definition

  • Ensure that the Platform Event is defined correctly. If the platform event is not firing then check its publishing behaviour. Publish After Commit will publish after the transaction is committed and Publish Immediately will publish the event Immediately.
Debug Salesforce Platform Events - SalesforceCodex
  • Ensure that all necessary custom fields are created and that their data types are appropriate for the data they’re supposed to handle.
  • Ensure that the user roles intended to publish or subscribe to the event have the right permissions.

2. Verify Event Publishing

  • Ensure the code or process that publishes the Platform Event is working properly. If Publish After Commit behaviour is set then the event will only published after the transaction is committed. So the code should be working properly.
  • Check any triggers, workflows, processes, or Apex code that publishes the event to ensure they are functioning properly.
  • Check for any validation rules or sharing settings that are preventing the event from being published.

3. Verify Event Subscription

  • Check that the subscribers (triggers, processes, etc.) are properly subscribed to the Platform Event. It can be checked on the Platform Event Setup page.
Platform Event Subscriber - SalesforceCodex
  • Check the subscription filters to ensure they match the criteria for the events being published.
  • Ensure that the subscriber code is active and working properly.

4. Monitor Event Delivery

  • Salesforce offers event monitoring tools that can be used to track event delivery. The Event Monitoring feature allows you to track the delivery of Platform Events.
Event Monitoring Setting - SalesforceCoeex
  • Check the EventLogFile object to see if the event was delivered and if any errors occurred during the process.
Event Log Object -SalesforceCodex

We can also use the Event Log File Browser (Beta) to see all event information for specific event types.

 Event Log File Browser - SalesforceCodex

5. External System Integration

  • If you’re integrating with other systems, make sure they’re receiving and sending events correctly. Check the endpoint URLs, credentials, and request formats.
  • If possible, access logs on external systems to diagnose issues with events not being sent or received as expected.

6. Use Debug Logs

Set up debug logs for all users who are publishing or subscribing to the event. This will include Apex executions and other system processes.

If flow or apex trigger is used to subscribed the Platform Event then we can also add a trace log for Automated Process.

Debug Trace Log - Salesforce Platform Event

After creating the logs (by replicating the issue), review them for errors or unusual behavior related to the Platform Event.

7. Debugging Subscribers

Whether the subscribers are Apex triggers, flows, or external systems, you must ensure that they respond to the events correctly.

Apex Triggers

For Apex subscribers, ensure that the trigger is active and the code properly handles incoming events. As with publishing, make sure to have test methods that simulate the event being handled.

Salesforce Flows

If you’re using Salesforce Flows to handle events, make sure the flow is active and properly configured to trigger the event.

External Systems

For external subscribers, make sure the endpoint is properly processing the events. This may necessitate reviewing the external system’s logs or employing debugging tools.

8. Review API Usage and Limits

Check for any API limits that may be affecting event publishing or subscribing, such as the number of events that can be published or delivered within a given time frame.

You can refer to API limits in the help document at Platform Event Allocations.

9. Test in Different Environments

If problems persist, try testing the events in a different Salesforce environment (such as a sandbox) to see if the problem is environment-specific.

10. Consult Salesforce Documentation and Community

You can also get help from Salesforce Communities like Trailhead, Stack Exchange or Reddit. There are so many questions already resolved in these communities, that you can refer them or ask your questions.

Related Posts

Ultimate Guide to Monitoring Platform Events using Streaming Monitor

Publish Platform Events from ASP.NET

Appointment Assistance Real Time Location Url Generation

Need Help?

Need some help in implementing this feature, connect on my LinkedIn profile Dhanik Lal Sahni.

You may also like

Leave a Comment