You are using an older browser that might negatively affect how this site is displayed. Please update to a modern browser to have a better experience. Sorry for the inconvenience!

Platform Events

By: Radha


Platform Events are used to deliver secure, scalable, and customizable notification within Salesforce or external app. Platform Event is based on Event-Driven Architecture. This is built in real time integration patterns in the Salesforce Platform which helps to reduce point-to-point integration.

Publishing platform event: 

We can publish the platform events in 3 ways:

  1. Publish Events Messaging using APEX.
  2. Publish Events Messaging using Declarative tools (Process Builder or Cloud Flow Designer Tool / Visual Work flow).
  3. Publish Events Messaging using Salesforce API from external app.

Not supported in Platform event: 

  1. The allOrNoneHeader API header is ignored when you publish platform events through the API.
  2. The Apex setSavepoint() and rollback() Database methods aren’t supported with platform events.

Subscription in Platform Event: 

  1. Apex triggers receive event notifications.
  2. write an “after insert” Apex trigger on the event object to subscribe to incoming events.
  3. Triggers receive event notifications from various sources—whether they’re published through Apex or APIs.
  4. Visualforce and Lightning component apps receive events through CometD.
  5. CometD is a scalable HTTP-based event routing bus that uses an AJAX push technology pattern known as Comet.
  6. In an external app, you subscribe to events using CometD as well.

Defining Objects and fields in Platform Events: 

Platform events can be created just like the custom objects. The biggest difference between Platform events and Custom object is suffix name for the api name. In Platform events, its api name suffix with __e where the custom object appends __c suffix to create api name. Unlike with custom objects, we cannot update or delete event record, or view event records in Salesforce User Interface.

Platform Events support only following custom fields type,

  1. Checkbox
  2. Date
  3. Data/Time
  4. Number
  5. Text
  6. Text Area (Long)

ReplayId System Field and Event Retention

  1. Salesforce stores platform events for 24 hours. You can retrieve stored events in API clients but not in Apex.
  2. Each event record contains a field, called ReplayID, that the system populates after the event is published.
  3. Each replay ID is guaranteed to be higher than the ID of the previous event, but not necessarily contiguous for consecutive events.
  4. You can retrieve all stored events, or you can specify the replay ID of an event as the baseline for the retrieved portion of events.

Steps to Create and Publish Platform Events:

  1. From Setup, Search Platform Events and Click on the Platform Events.

platform events salesforce

  1. Click on New button to create Platform Events.

  1. Provide the name for the Platform Events.

platform events salesforce

  1. Create a custom field to show the Notification from this field.

platform events salesforce

  1. Create an Apex Class to publish the Platform Event


platform events salesforce

  1. Create a Lightning Component to subscribe the Platform Event through cometd JavaScript client and get the real-time notification through this component.


platform events salesforce


platform events salesforce


platform events salesforce

  1. From Setup > App Manager > Click Edit on Service Console App.

platform events salesforce

  1. Click on Utility Bar Tab. Click on Add button and choose helpNotification component to add lightning component to Service Console App.


  1. Provide the component name as Help and check Load in background apps open option.

  1. Go to the Service Console App. You will see the notification as shown below and Help utility bar.