Skip to main content

Salesforce Platform Events – What are they & how to use

So, what’s platform event in basic terms and how is it helpful to me?
Consider this, a platform event is just like another custom object but this would only be referred by external systems to communicate with Salesforce. To put this in a scenario when a certain system posts data on a Salesforce endpoint then that data should be fetched and the data in Salesforce should be updated. Of course, you can use too many lines of code to continuously fetch and retrieve the data from the endpoint or just wait for data to be posted based on which an event shall be triggered and the next processes shall follow. Now, this is where platform event comes into the picture, instead of writing lines and lines of codes and continuously requesting and checking if the data is posted we can just have a platform event trigger notify us and then have your logic do the rest of the heavy lifting.
Now, that we have convinced you why Platform events are good, let’s give you a quick walkthrough of it. From your Setup, in quick find box search for “Platform Events” then click on “New Platform Event” then just like your Custom Object enter the label and API name for your Platform Event. Once completed then add any Custom Fields you want. Now, for demo purpose we will be naming our platform event as “Demo Event” and we will be adding two fields to it named Account Number and Account Name.
Note- Platform event end with “__e” instead of “__c” notifying that they are platform event and differing from custom object.
Creating new Platform Event
Creating new Platform Event
Once you are satisfied with you Platform Event and your fields click on “New” trigger for your platform event, then add the below code.
Platform Event Trigger
Platform Event Trigger
Now, log into Workbench then under Utilities section click on “Rest Explorer”, now, in your execute section after your version number just append “/sobjects//” e.g.-”/services/data/v42.0/sobjects/Demo_Event__e/” and in request body just add the below JSON and click on execute, once the request is processed your record will be updated.
Demo Request
Demo Request
Account Name before processing the request
Account Name before processing the request
Updated Account Name after processing the request
Updated Account Name after processing the request





Comments

Popular posts from this blog

Define & View Custom Big Object

Define a Custom Big Object: You can define custom big objects with Metadata API or in Setup. After you define and deploy a big object, you can view it or add fields in Setup. After you’ve deployed a big object, you can’t edit or delete the index. To change the index, start over with a new big object. To define a big object in Setup, see Salesforce Help. View a Custom Big Object in Setup After you’ve deployed your custom big object, you can view it by logging in to your organization and, from Setup, entering  Big Objects  in the  Quick Find  box, then selecting  Big Objects . Click the name of a big object, to see its fields and relationships. View a Custom Big Object in Setup After you’ve deployed your custom big object, you can view it by logging in to your organization and, from Setup, entering  Big Objects  in the  Quick Find  box, then selecting  Big Objects . Click the name of a big object, to see its fields and ...

ASYNC SOQL - with Big Objects

Async SOQL Async SOQL is a method for running SOQL queries when you can’t wait for immediate results. These queries are run in the background over Salesforce big object data. Async SOQL provides a convenient way to query large amounts of data stored in Salesforce. Async SOQL is implemented as a RESTful API that enables you to run queries in the familiar syntax of SOQL. Because of its asynchronous operation, you can subset, join, and create more complex queries and not be subject to timeout limits. This situation is ideal when you have millions or billions of records and need more performant processing than is possible using synchronous SOQL. The results of each query are deposited into an object you specify, which can be a standard object, custom object, or big object. The limit for Async SOQL queries is one concurrent query at a time. Async SOQL Versus SOQL SOQL and Async SOQL provide many of the same capabilities. So when would you use an Async SOQL query instead of s...

Publish Paltform Events

Publishing Platform Events The Salesforce enterprise messaging platform offers the benefits of event-driven software architectures. Platform events are the event messages (or notifications) that your apps send and receive to take further action. Platform events simplify the process of communicating changes and responding to them without writing complex logic.  Publishers and subscribers communicate with each other through events.  One or more subscribers can listen to the same event and carry out actions. Here we will see how many ways you can able to publish the 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.Here is the simple platform event object we will be using in the examples here Here are the different ways you can able to publish the platform events in Salesforce Option 1: Using Proces...