Salesforce Platform Events
Salesforce has a unique way to approach different customers. Salesforce allows the admin of a company to broadcast any particular message to various other terminals. For example, if a manager wants to send a message to every employee in the organization then platform events can be used to perform this task.
Meanwhile, check out our YouTube video on Salesforce Tutorial
- What are Salesforce Platform Events?
- Challenges faced in Point-to-Point Integrations.
- What is Event-Driven Architecture in Salesforce?
- Use of Platform Events in Salesforce.
- Use Cases of Platform events in Salesforce
- How to publish Platform Events in Salesforce?
- How to Define Platform Events?
- How to Add a Field to the Platform Event?
What are Salesforce Platform Events?
A PlatformEvent is a special type of Salesforce entity that is similar to Salesforce custom objects. You can create a platform event definition and then add custom fields in custom objects.
The events get sent to the user anyway whether the user acknowledges it or not. Platform events are the event messages or notifications that your apps send and receive to take further actions. It simplifies the process of communicating changes and responding to them without writing complex logic.
Publishers and subscribers communicate with each other through these events. One or more subscribers could listen to the same events and carry out the actions required to perform.
Challenges faced in Point-to-Point Integrations
Before the usage of Salesforce platform events, the other applications were connected by point-to-point integration methods. But there are many challenges faced by people while using point-to-point integration methods and thus, it leads to big problems in the organization. Some of the limitations of point-to-point integration methods are-
- Scalability– Inclusion, and removal of particular entities one by one is quite time-consuming and is a tedious process.
- Tight Coupling– Every point is integrated with some of the other dependencies which makes the maintenance task tough for the users.
- Non Ubiquitous Communication– Inconsistent and disparate data exchange formats.
The solution to these problems is the adoption of Event-Driven Architecture
What is Event-Driven Architecture in Salesforce?
Event-Driven Architecture is the brand new manner of enforcing enterprise common sense via leveraging High Volume Platform Event. The Event-Driven Architecture is likewise referred to as a publisher/subscriber version in which the publishers and the subscribers don’t recognize every difference and might co-exist independently. Also, the main factor of Event-Driven Architecture is that there is a single channel which deals with all the communication thus, maintaining the data integrity of the organization. The communication between the writer and the subscriber is set up through a subscription channel.
In that manner, every entity is absolutely unbiased of becoming a member or leaving the subscription channel. Because of the loose coupling nature, it is also simpler for the developer to broaden every issue independently.
When a publisher publishes an event it goes to the Event Bus and is available for subscription through a subscription channel and can pass on to the subscribers who already subscribe to the corresponding channel.
Salesforce Platform Events allow the application of Event-Driven Architecture thus, helping integrate different apps together. Salesforce events get integrated with third-party applications. The internal Salesforce apps can be considered as publishers or subscribers or the third-party apps can also be considered as publishers or subscribers.
Learn Salesforce from the scratch with Intellipaat’s Salesforce Tutorial!
Use of Platform Events in Salesforce
Here is a list of uses of Platform Events in Salesforce-
- Delivering Custom Notifications- Platform events are a part of Salesforce’s corporation messaging platform. The platform offers an event-pushed messaging structure to allow apps to talk outside and inside of Salesforce.
- Real-time Event Monitoring Object- For most platform events used in Real-Time Event Monitoring, corresponding Salesforce event objects store the event data.
- Encrypting Platform Event Messages at Rest in the Event Bus- For increased security, you can enable encryption of platform event messages while they’re stored in the event bus in a Shield Encryption org.
- Publish Platform Event Messages with Salesforce APIs- External apps use an API to publish platform event messages. Publish events by inserting events in the same way that you insert objects. You can use any Salesforce API to create platform events, such as SOAP API, REST API, or Bulk API.
The messages sent by the admin as notifications have a particular limit. The maximum event message size that you can publish is 1 MB. If your event object has hundreds of custom fields or many long text area fields, you could hit this limit. In this case, the publishing call gets an error.
Use Cases of Platform events in Salesforce
Salesforce and external systems communicate through platform event messages. Some Use Cases are-
- News organizations send notifications to subscribed customers or paid customers whenever any big news comes up.
- An external product app notifies Salesforce of merchandise return.
How to publish Platform Events in Salesforce?
After a platform event has been defined in your Salesforce org, Publish Event messages from a Salesforce app using processes, flows, or Apex or an external app using Salesforce APIs.
- Publish Event Messages with Flows – Use flows to publish event messages from a Salesforce app as a part of few-person interactions, an automatic process, Apex, or workflow action.
- Publish Event Messages using Salesforce Declarative Tools like Process Builder – We can use the Salesforce platform events process builder to publish event messages from a Salesforce app as part of an automated process. These Declarative Tools in Salesforce help a lot to publish Event Messages in Salesforce
- Publish Event Messages with Apex – Use Apex to publish event messages from a Salesforce app. To publish event messages, call the EventBus.publish method.
For example, if you defined a custom platform event called Low Ink, reference this event type as Low_Ink__e. Next, create instances of this event, and then pass them to the Apex method.
- Publish Event Messages with Salesforce APIs – Publish events by inserting events in the same way that you insert objects. You can use any Salesforce API to create platform events, such as SOAP API, REST API, or Bulk API. When publishing an event message, the result that the API returns contains information about whether the operation was successful and the errors encountered. If the success field is true, the publish request is queued in Salesforce and the event message is published asynchronously.
- Get the Status of Asynchronous Platform Event Publish Operations (Beta) – High-quantity platform occasions are posted asynchronously. With submit popularity occasions, you could music the popularity of publishing operations and take the vital actions. Enable popularity occasions at the high-quantity platform occasion you’re inquisitive about tracking.
Want to learn Salesforce right from scratch, enroll yourself in our Salesforce Certification Training now!
Courses you may like
How to Define Platform Events?
- Go to Setup, enter Platform Events in the Quick Find box, then select Platform Events.
- On the Platform Events page, click New Platform Event.
- Create a Notification platform event with the following settings:
- Label: Notification
- Plural Label: Notifications
- Object Name: Notification
- Description: Real-time notifications
- Click Save.
Preparing for a Salesforce job? check out our list of Salesforce Interview Questions and Answers and ace your Salesforce job interview.
How to Add a Field to the Platform Event
- On the Notification platform event page, click New in Custom Fields & Relationships.
- Select Text as the field data type
- Click Next
- Set the following values:
- Field Label: Message
- Length: 255
- Field Name: Message
- Description: The notification message
- Required: Check the box next to “Always require a value in this field in order to save a record”.
- Click Save
Examples of Platform Events in Salesforce
Here is a list of examples where a platform event is used-
- Printer Supply Automation- When the platform event-triggered flow receives a Printer Status event, the flow finds the asset record that’s associated with the printer. The flow evaluates whether the printer has low ink or paper and if so, calls an Apex action to order ink or another action to order paper. The flow starts when it receives a Printer Status platform event message.
- Pure Aloe App- This sample app for a fictional agricultural, manufacturing, and retail company demonstrates how to simplify complex processes and integrate external systems with Lightning components, Salesforce Flow, and platform events. The app helps the Pure Aloe company manage the aloe harvest and sell derived aloe products through a distributor channel
To access the sample code on GitHub, check out The Pure Aloe App.
Have any more queries regarding Salesforce Developer Jobs, Join our Salesforce Community page and get your queries answered.
The post Salesforce Platform Events appeared first on Intellipaat Blog.
Blog: Intellipaat - Blog
Leave a Comment
You must be logged in to post a comment.