Sunday 3 May 2020

Publish platform events from an external application


Publish platform events from an external application using Salesforce API

External apps use an API to publish platform event messages. You can publish events by creating records of your event in the same way that you insert sobjects. You can use Salesforce APIs to create platform event records.

Let's look at one example:

Step1: Create a platform Event Object


As you can see in the screenshot I created one PE and added a custom  text field "Account_Name__c"

Step2: Create a trigger on PE object to subscribe to Platform Event 




This after trigger will subscribe to Platform Event and create accounts with the event message name.

Step3: Publish Platform Event

You can use sobject REST endpoint to publish:


/services/data/v48.0/sobjects/Account_Event__e/


Request body for a POST request will be like this :


{
  "Account_Name__c":"New PE Test Account"
}






Like this, you can publish a platform event from outside salesforce and you add your all logic in PE trigger.

Related Post:


1 comment:

  1. Over my years in business and having attending hundreds of networking events, I've heard this or a similar phrase many, many times. I've also been told that business networking doesn't work for everyone and for a while I reflected on this point to see if I agree and actually, I don't. industry Network

    ReplyDelete