An Introduction to Salesforce Platform Events is part of the is part of the blog post series: Integrating Salesforce With Other Apps – A Series!
Salesforce Platform Events are an event-driven architecture provided by the Salesforce platform. They allow for the creation, publishing, and subscription of custom events within an organization’s Salesforce instance. This makes it possible for different parts of an organization’s Salesforce implementation to communicate with one another in a flexible and scalable manner.
What are Salesforce Platform Events?
Create, publish, and subscribe to Salesforce Platform Events within your Salesforce organization. Triggered by various parts of Salesforce (Apex code, Lightning components, or Process Builder) these events carry data payloads to communicate information between different parts of the system.
Platform events are based on Kafka-style event-based messaging.
How do Salesforce Platform events work?
The Salesforce Platform event architecture operates on the publish-subscribe pattern, where an event is published, and multiple subscribers can receive and process the event. When a platform event is published, it creates a new record in the platform event object, which subscribers can then consume. Subscribers can be implemented as Apex triggers, Process Builder flows, or Lightning components and they receive the platform event record and can process the data payload contained within.
Why are Salesforce Platform events useful?
Salesforce Platform events provide a flexible and scalable way for different parts of an organization’s Salesforce implementation to communicate with one another. They allow for the creation of custom events that can be tailored to an organization’s specific needs and can be used to create complex event-driven systems within Salesforce. This makes it possible for different parts of an organization’s Salesforce implementation to communicate and interact with one another in real time, leading to more efficient and effective business processes.
When to use Salesforce Platform Events
Salesforce Platform Events are useful in a variety of other use cases, including:
- Real-time integration with external systems: Salesforce Platform events can integrate with external systems in real time. A platform event is triggered whenever a record is updated in Salesforce, and an external system can consume the event to perform some action.
- Event-driven automation: Platform events can be used to trigger automation within Salesforce. For example, a platform event can be triggered whenever a lead is created, and a subscriber can be used to assign the lead to a salesperson automatically.
- Multi-org communication: Salesforce Platform events can be used to communicate between different Salesforce organizations, enabling organizations to share data and collaborate in real-time.
- Streamlining business processes: Salesforce Platform events can streamline business processes by allowing different parts of an organization’s Salesforce implementation to communicate and interact in real-time.
Example use case using Salesforce Events
What if you wanted to track changes to a specific record type in Salesforce? You want to be able to notify a particular group of users whenever a change is made to these records, and they want to ensure that the information is delivered in real-time.
To accomplish this, you can create a custom platform event in Salesforce to represent the change to the record. This platform event can be triggered whenever a change is made, and it can carry the relevant data payload (such as the record ID and the type of change made).
Next, you can create a subscriber for the platform event as a Lightning component. This component can display the notification to the relevant users whenever the platform event is triggered. The notification will be delivered in real time after the platform event is published.
Salesforce Platform events provide a flexible and scalable solution for organizations to track record changes and send real-time notifications to relevant users.
Wrapping it Up
Salesforce Platform events are a powerful tool that can be used to build complex, event-driven systems within Salesforce or even outside of it.
Allowing different parts of an organization’s Salesforce implementation to communicate and interact with one another in real-time can help organizations achieve their business goals more efficiently and effectively.