Author - Sonali Sharma Post Views - 5 views

Steps to Create and Publish a Platform Event in Salesforce

Platform Events are a feature in Salesforce that enable event-driven communication between systems. They allow Salesforce and external systems (like MuleSoft, external applications, or middleware) to communicate asynchronously through a publish–subscribe model.

Platform Events are designed to support real-time integrations and loosely coupled system architectures.

Platform Event Definition

A Platform Event is a special type of Salesforce object that represents something that has happened in the system.

Examples:

    • A policy is created
    • A claim is updated
    • A payment is processed
    • A record is approved

Instead of directly calling another system, Salesforce publishes an event, and subscribed systems react to it.

This is known as event-driven architecture.

Create a Platform Event:

    1. Go to Setup.
    2. Search Platform Event.
    3. Click New and type the name of the event you want to create.

A Platform Event (example):

Event Name: Order_Download_Event__e

Example fields:

    • Order_Number__c
    • Customer_Id__c
    • Order_Type__c
    • Order_Date__c
    • Order_Status__c
    • Payment_Method__c 
    • Shipping_Address__c 
    • Payload__c
    • Source_System__c

An event sends Order transaction data to Salesforce asynchronously.

Publishing the Platform Event

The publisher is responsible for creating and sending the event after Order data is downloaded and validated.

Publishing can be done using Apex, middleware, or an API integration.

Example Apex Publisher

Order_Download_Event__e eventMsg = new Order_Download_Event__e(

    Order_Number__c = orderNumber,

    Customer_Id__c = customerId,

    Order_Date__c = orderDate,

    Order_Amount__c = orderAmount,

    Order_Status__c = orderStatus,

    Payment_Method__c = paymentMethod,

    Shipping_Address__c = shippingAddress,

    Payload__c = orderJson,

    Source_System__c = ‘Test Integration’

);

Database.SaveResult result = EventBus.publish(eventMsg);

Publishing Flow

    1. Order file is downloaded.
    2. Data is parsed and validated.
    3. Event payload is constructed.
    4. Platform Event is published to the Salesforce Event Bus.

Once published, Salesforce manages delivery to all subscribers.

Why Use Platform Events?

Platform Events are useful when:

    • Multiple systems need to be notified about a change.
    • You want loose coupling between systems.
    • Real-time or near-real-time communication is required.
    • You want scalable integration architecture.
    • You want to avoid tight point-to-point integrations.

Leave a Reply

Your email address will not be published. Required fields are marked *

fiteesports.com rivierarw.com cratosroyalbet betwoon grandpashabet grandpashabet giriş deneme bonusu veren siteler casino siteleri