What is platform event in salesforce

image

  • Platform events are special kinds of entity similar to custom object
  • You can publish and consume platform events by using Apex or a REST API or SOAP API.
  • Platform events integrate with the Salesforce platform through Apex triggers. …
  • Unlike custom objects, you can’t update or delete event records. …

More items…

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.

Full
Answer

Table of Contents

What are the different platforms in Salesforce?

With that, here are the tools you can use to build apps on Lightning Platform:

  • Salesforce Environments. A secure and isolated development environment for developers and admins to test ideas, accelerate app development, and customize the platform. …
  • Heroku. It lets you extend Salesforce by building engaging experiences through custom apps. …
  • mySalesforce. …
  • myEinstein. …
  • Salesforce App Cloud. …

How to subscribe to Salesforce platform event?

Subscribe Channel Listener. Step 1: Add Salesforce Subscribe channel listener and configure as shown below: Step 2: Log the actual platform event which will be in the Object format like below: The sample event would look like: Step 3: Now add Transform message to extract the event message that is encapsulated in the above Object.

How to create your first app in Salesforce?

  • To create application in lightning, Click File | New | Lightning Application.
  • Enter the name, and click Ok. E.g. appName.app resource. You may set name accordingly.
  • Now use c:helloWorld to refer the component helloWorld.cmp using the default namespace c. If your organization has a registered namespace, you can use it to reference. …

What is a platform event?

Platform events are the event messages that your apps send and receive. They simplify the process of communicating changes and responding to them without requiring you to write complex logic. Publishers and subscribers communicate with each other through platform events. One or more subscribers can listen to the same event and carry out actions.

image


What are platform events used for in Salesforce?

Use platform events to connect business processes in Salesforce and external apps through the exchange of real-time event data. Platform events are secure and scalable messages that contain data. Publishers publish event messages that subscribers receive in real time.


What is a platform event message Salesforce?

A platform event is a special kind of Salesforce entity, similar in many ways to an sObject. An event message is an instance of a platform event, similar to how a record is an instance of a custom object. Unlike custom objects, you can’t update or delete event records.


What is platform event in process builder?

Processes built in Process Builder can subscribe to platform events and receive event messages published through Apex, APIs, flows, and other processes. Processes provide an autosubscription mechanism. To subscribe a process to a platform event, build the process to start when it receives a platform event message.


What is platform event flow in Salesforce?

Platform Events in Salesforce Platform Event is based on Event-Driven Architecture which enable apps to communicate inside and outside of Salesforce. Platform events are based on the publish/subscribe model and work directly with a message bus which handles the queue of incoming events and processes listening for them.


What are platform events in LWC?

Platform events enable the flow of event messages within Salesforce and to or from external apps. Apps on the Salesforce platform use an Apex method to publish events and an Apex trigger or the empApi Lightning component to consume events.


How do you trigger a platform event?

After an event message is published, the after insert trigger is fired. To create a platform event trigger, use the Developer Console. Click the Setup icon, select Developer Console, and click File | New | Apex Trigger. Provide a name and choose your event for the sObject, and click Submit.


How do I create a platform event in Salesforce?

Define a Platform EventFrom 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. … Click Save.


Can we query platform events?

For platform events, you can query usage data for these metrics. The first value is the metric name value that you supply in the query. For change data capture events, you can query usage data for these metrics. The first value is the metric name value that you supply in the query.


How do I test a platform event in Salesforce?

Add Apex tests to test platform event subscribers. Before you can package or deploy Apex code, including triggers, to production, it must have tests and sufficient code coverage….Testing Your Platform Event in ApexEvent and Event Bus Properties in Test Context. … Deliver Test Event Messages. … Test Retried Event Messages.


How do I debug a platform event in Salesforce?

Set Up Debug Logs for Event SubscriptionsAdd a Trace Flag Entry for the Default Automated Process User. To collect logs for an event subscription, add a trace flag entry for the Automated Process entity in Setup.Add a Trace Flag Entry for the Overridden User.


How do I publish a platform event in Apex?

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.


Which type of flow can be a subscriber to a platform event?

Launch flows or resume running instances of flows, called interviews, when platform event messages are received. Subscribed flows and interviews can receive event messages published through Apex, APIs, flows, and other processes.


Platform Event

A platform event is much the same as another custom item yet this would just be alluded by outside systems to speak with Salesforce. To place this in a situation when a specific system posts information on a Salesforce endpoint then that information ought to be gotten and the data in Salesforce should be updated.


Advantages of Salesforce Platform Events

Clients can run organizations quicker on an event-driven architecture.


What is platform event?

Platform events are based on a publish-subscribe architecture. Apps can publish platform events by using Apex or one of the Salesforce platform APIs (SOAP, REST, or Bulk API). In addition, declarative tools such as the Lightning Process Builder or Cloud Flow Designer can publish platform events.


How long do SOQL events last?

Unlike custom objects, however, events persist for only 24 hours. And unlike records, there is no user interface that lists them, and you can’t query them through SOQL. For a more in-depth exploration of platform events, refer to the Platform Events Basics module and the Platform Events Developer Guide.


What is platform event in Salesforce?

Platform events enable the flow of event messages within Salesforce and to or from external apps. Apps on the Salesforce platform use an Apex method to publish events and an Apex trigger or the empApi Lightning component to consume events. As an alternative to code, you can publish events with declarative tools, such as Process Builder and Flow Builder. External apps publish events using the sObject API and consume events using CometD. As you can see, there is a lot of flexibility in how you choose to use Platform Events!


What is platform event?

Platform events are similar to generic events but offer more powerful customization. With platform events, you can publish any custom data. You define the schema of event data at a granular level as typed fields. Also, you can use platform events in native Salesforce platform apps and external apps alike.


What is a trigger in Salesforce?

The external system publishes a platform event to alert Salesforce to the merchandise return. An event listener (a trigger) in Salesforce receives the event and performs some actions. For example, the trigger might alert the sales representative to the return, and send a confirmation email to the customer.


What happens when an opportunity closes in Salesforce?

When an opportunity closes in Salesforce, your company has won a deal with a customer. Let’s say you use vendors to ship products associated with an opportunity. Each vendor has an external app that processes shipment orders. The external app listens to platform events. When an opportunity closes, a trigger, which is part of a product order app in Salesforce, fires and publishes a platform event message. Each vendor app is notified of the event and creates a shipment order for a specific product.


What is an event in business?

Event. A change in state that is meaningful in a business process. For example, placement of a purchase order is a meaningful event, because the order fulfillment center expects to receive a notification before processing an order. Event message. A message that contains data about the event.


What is event based communication?

Event-based communication takes place in real-time—or, more accurately, in near-real time. Radio waves travel at the speed of light, but event-based software and hardware systems typically have some latencies.


Can consumers receive and react to the same events?

Any number of consumers can receive and react to the same events. When an event occurs, systems obtain this information and can react to it in near-real time. Systems that send events and others that receive the events don’t have dependencies on each other, except for the semantics of the message content.


Custom Events

You can use the following types of events to generate and deliver custom messages.


Custom and Data Event Comparison

For a comparison of custom and data events, see Streaming Event Features in the Streaming API Developer Guide.


Standard Events: Security, Apex, and Monitoring

Salesforce publishes the following examples of standard platform events. These predefined events enable monitoring of security-related actions and user actions in Salesforce.


Event-Like Features

The following features can trick you into being streaming events, but they’re not.


Standard Fields

Platform events include standard fields. These fields appear on the New Platform Event page.


Custom Fields

In addition to the standard fields, you can add custom fields to your custom event. Platform event custom fields support only these field types.


ReplayId System Field

Each event message is assigned an opaque ID contained in the ReplayId field. The ReplayId field value, which is populated by the system when the event is delivered to subscribers, refers to the position of the event in the event stream. Replay ID values are not guaranteed to be contiguous for consecutive events.


EventUuid System Field

A universally unique identifier (UUID) that identifies a platform event message. This field is available in API version 52.0 and later. The API version corresponds to the version that an Apex trigger is saved with, or the version specified in a CometD subscriber endpoint.


API Name Suffix for Custom Platform Events

When you create a platform event, the system appends the __e suffix to create the API name of the event. For example, if you create an event with the object name Low Ink , the API name is Low_Ink__e. The API name is used whenever you refer to the event programmatically, for example, in Apex.


Platform Event Trigger flow

With platform event–triggered flows, you can do all your automation in one place. Users can trigger a Flow when a platform event message is received. Unlike Process Builder, users can access all available records when a Flow is invoked by the platform event message.


What is Platform Event ?

Platform Event is based on Event-Driven Architecture which enable apps to communicate inside and outside of Salesforce. Platform events are based on the publish/subscribe model and work directly with a message bus which handles the queue of incoming events and processes listening for them.


Recording

In this session we will talk about why we should use Platform Event Trigger flow and how to create platform event flow in Salesforce.


Platform Event Considerations

If platform event–triggered flows, paused flow interviews, and processes are subscribed to the same platform event, we can’t guarantee which one processes each event message first

image


Types of Platform Events

  • 1. Standard PE
    These are the predefined events provided by Salesforce itself. Some examples of Standard PE are: 1. AssetTokenEvent: Monitors OAuth 2.0 authentication activity. 2. BatchApexErrorEvent: Reports error encountered in batch apexjobs.
  • 2. High-Volume PE
    These are custom PE used to publish and process millions of events effectively and to scale your event-based apps.

See more on emizentech.com


Defining Platform Events

  • Below are the steps to create a custom Platform Event in Salesforce: 1. 1. In Setup, select Platform Eventsin the quick find. 2. 2. Click New Platform Event. 3. 3. Fill in the standard fields. 4. 4. Platform Events provide two types of publishing mechanisms. Publish after commit is used to publish the event only after the transaction is successfully committed. Publish Immediatelywill p…

See more on emizentech.com


Publishing Platform Events

  • Below are several ways to publish a platform event after defining the same: 1. Publish Event Messages with Flows 2. Publish Event Messages with Processes 3. Publish Event Messages with Apex 4. Publish Event Messages via APIs Below is the code snippet to publish platform event with Apex:

See more on emizentech.com


Subscribing Platform Events

  • Below are the several ways to receive the platform event: 1. Subscribe to Platform Event Messages with Flows 2. Subscribe to Platform Event Messages with Processes 3. Subscribe to Platform Event Notifications with Apex Triggers 4. Subscribe to Platform Event Notifications in a Lightning Component 5. Subscribe to Platform Event Notifications with CometD(Workbench)

See more on emizentech.com


Conclusion

  • We hope you find this post helpful and will guide you to define, publish, and subscribe to platform events. To know more, don’t hesitate to connect with us. Emizentech, a Salesforce development company, is always there to serve you the best.

See more on emizentech.com

Leave a Comment