Platform Events in Salesforce is a powerful feature that enables event-driven architecture within the Salesforce ecosystem. This enables integration and communication between different parts of your Salesforce org and external systems in a scalable and loosely coupled manner. Platform events are used to send and receive events in real-time.
We can monitor the usage of platform events but we can’t see platform event messages. Using the Salesforce AppExchange package Streaming Monitor we can check event data also. We can use this package to monitor all streaming events like PushTopic events, generic events, standard and custom platform events, change data capture events, and monitoring events. This post will explain how to use this package to monitor platform event data.
ABC Company need to send order information created into Salesforce to third-party systems for further processing like invoicing, fulfilment etc. This information should be sent to third-party systems even if their system is down for some time.
We will create a platform event and push messages to the third-party system. Third-party systems can subscribe to this platform event and use it for processing. These messages are available for 72 hours so they can get all messages even system is rebooted.
The steps to monitor platform events are as below
- Create Platform Event
- Install Streaming Monitor
- Subscribe to Platform Event in Package
- Test Functionality
1. Create a Platform Event
As per the above solution, we need to send order information to the third-party system. Let us create a platform event Order Created (Order_Created_Event__e) that will be used for sending message to third party. Create the below fields in this platform event
|Field Data Type
This event is published when a new product order is created in Salesforce. Let us create a flow that will publish platform events when an product order is created.
Create a record trigger flow on the ProductOrder object. Set flow object and entry criteria like the below table.
|A record is created or updated
|All Conditions Are Met (AND)
|When to Run the Flow for Updated Records
|Every time a record is updated and meets the condition requirements
|Optimize the Flow for
|Actions and Related Records
The below Condition Requirements need to be set
Add the Create Record element and add values from the current record to platform event properties. Check the below image for value assignment. You can assign values based on your assignments.
Save and activate this flow for publishing platfform event.
2. Install Streaming Monitor
Install Streaming Monitor from AppExchange to your Salesforce Org. It is a free app developed by Salesforce Labs. You should try this application first in sandbox org. Once successfully tested and required then install in production.
Once it is installed it will show in the Installed Package page. Now we can test this application to monitor platform events.
3. Subscribe to the Platform Event in Streaming Monitor
We can set subscriptions to platform events from Streaming Monitor. This is lightning app and is accessible similar to other object.
This app can be used to monitor almost all events. We will subscribe to our custom platform event. Select Subscribe to a channel in actions. Set properties like below
|Custom Platform event
|Order Created Event (Change based on your given name)
|This will automatically generated
|No replay (default for all new messages- let this be selected)
Replay past events – this will show previous messages as well
Replay Id- This will show message after given replay id
4. Test Feature
To test this feature we need to create or update Product Order record. Once it is created or updated, it will show messages in Streaming Monitor.
Need some kind of help in implementing this feature, connect on my LinkedIn profile Dhanik Lal Sahni.