Integrating/Subscribing SalesForce platform events in SAP Cloud Platform Integration using JWT OAuth Bearer Flow – Part 1
This blog demonstrates how to integrate Salesforce platform events in SAP Cloud platform integration(SAP CPI).
As part of this demonstration, we will be creating the platform events in Salesforce lightning environment and subscribing to these events in SAP CPI using ADVANTCO SFDC adapter.
This blog is divided into 2 parts. We will cover the Salesforce side of things in this part and Part 2 will cover mostly the SAP CPI side.
To start with let me provide some brief on platform events and event-driven software architecture.
An event-driven software architecture comprises of Events, Event Messages, Event Producers and Subscribers. The main benefit of event-driven software architecture is its capabilities of decoupling the Event producers from event subscribers.
An event is basically a change in state.
Its a message that contains data about the event occurred.
Event producer is a publisher of an event over a defined channel.
Event consumer is subscriber to a event channel and receives messages from the event channel.
Enterprise messaging in Salesforce is event based and complies to the fundamentals of event driven software architecture. Platform events in Salesforce are the event messages that simplifies the process of communication between the producer and consumers.
I think its enough of the theoretical aspects about platform events and event-driven software architecture. Let’s switch to see some artifacts built in Salesforce environment for the Salesforce and CPI integration using OAuth JWT bearer flow.
Just FYI, This is my first development in Salesforce and I have kept this limited to the Platform events and How to trigger the events.
Okkkkk… Time to see some interesting stuff…
I started with signing up on Salesforce lightning environment.
After completing the login procedure, The goal is to set up a platform event, Process builder(to publish the event), and a connected application to expose the event to the outside world( SAP CPI in our scenario).
Below are the 3 steps performed in Salesforce lightning environment:
- Creation of Platform events: Search for platform events in Salesforce Home screen, and you will see below screen.
Click on New platform event and create one for your scenario.
I have created LeadInfo1 platform event, which will trigger whenever a new lead is created or changed.
OK, so now the platform event is created. Next, we will be creating a Process Builder, to trigger the event whenever a lead gets created or changed.
- Creation of Process Builder: Search for process builder on the Home screen, and you will see below screen.
I have created Lead_Event_New to trigger the platform event, whenever a lead gets changed or a new one got created.
The above screenshots depict that whenever a Lead gets created or changed, create a record of type LeadInfo1 with FirstName details changed/created.
- Create a connected application: the last step is to create a connected application to create a connection between SF and any third-party application.
Connected app details for your reference:
Below are the details to connect to Salesforce using OAuth 2.0
Cool, we are all set to trigger events in Salesforce. To check the details of the triggered events, we can use the Workbench tool.
With the help of Workbench tool, we can check the payload of the event triggered.
Now we can test the event details by changing the Lead details.
To go to the lead, go to the Sales console as shown in the below screenshot.
Open lead and change the user details as shown below
This should trigger the platform event. We can check the details updated in the Workbench tool as shown in the screenshot below.
We can see the updated First Name details in the above payload. This message is in the event bus queue and is ready to be subscribed.
In the next blog, we will see how can we subscribe to the platform events in SAP CPI.
Stay tuned and stay safe, Happy Learning!
Thanks for sharing step by step guide, Gopesh!
Waiting for the second part!
Thanks for your comments!
You can check part 2 here.
Great blog ..
I am not able to see the payload in Salesforce Workbench, any idea why?