Tech Force

Technical Blog & Projects about Salesforce

Follow publication

How To Publish Platform Events

Publish Salesforce Platform Events with different technologies

Techletters
Tech Force
Published in
8 min readFeb 4, 2022

--

How to publish Salesforce Platform Events. Picture by Buffik from Pixabay.

Salesforce Platform Events can be created in different ways using

  • Flows
  • Process Builder
  • Apex
  • Salesforce APIs

We will take a look at all the variants in this story, let’s kick start right away.

Define a Platform Event

Before we can publish any Platform Event, we need to define one. Let’s create a Platform Event opportunityCreated. Navigate to Setup > Integrations > Platform Events and select New Platform Event. Fill in the below details and save.

Create a new Platform Event in Salesforce.

Navigate to the Platform Event and create the following Custom Fields.

  • we will fill the fields opportunityAmount, opportunityName and opportunityStage from the Opportunity when publishing the Platform Event
  • eventType will contain the Event Name and originatedFrom will be filled from the trigger technology and contain either Flow, Process Builder, Apex or API
Define Custom Fields on the Platform Event.

Alright, our Platform Event structure is ready.

Subscribe to the Platform Event

Next, let’s subscribe to the Platform Event to verify that the publishing (which we do in the next step) works fine. Navigate to Setup > Object Manager and create a new Custom Object Event Log (API Name: EventLog__c) with following custom fields.

Create a Custom Object in Salesforce with Custom Fields to Log the Platform Events.

Navigate to Setup > Process Automation > Flows select New Flow and then Platform Event-Triggerd Flow. Use the Freeform to create the new Flow.

--

--

Tech Force
Tech Force

Published in Tech Force

Technical Blog & Projects about Salesforce

Techletters
Techletters

Written by Techletters

#ai #datascience #salesforce #crypto #kafka #python — Follow me: https://techletters.medium.com/membership

Responses (2)

Write a response