Build Real-Time TV Dashboards with Salesforce Data, Platform Events & a Raspberry Pi – Part 2 – Salesforce Setup
This blog post is Part 2 of the blog post series on Building Real-Time TV Dashboards with Salesforce Data, Platform Events & a Raspberry Pi.
Part 1 – The Intro
\> Part 2 – Salesforce Setup
Let’s continue right from where we left off and setup our Salesforce Environment.
We need a Salesforce Org. Trailhead Playground or a Developer Edition would be the best when learning or trying out anything Salesforce. Get either one of these and let’s get started.
To communicate our Salesforce data to the dashboard(on the Raspberry Pi) in real-time, we will be using Platform Events.
Platform Events help deliver custom notifications within the Salesforce platform and in external apps. They facilitate event-based communication using the publisher-subscriber model.
So in our case, the Publisher is our Salesforce Org and the Subscriber is the Dashboard LWC App on the Raspberry Pi.
There are two types of Platform events, Standard and Custom.
Standard Platform Events – Available Out of the Box and are automatically published when ever a specific event occurs.
E.g. Change Data Capture Events (CDC) – Salesforce Change Data Capture publishes change events, which represent changes to Salesforce records. Changes include record creation, updates to an existing record, deletion of a record, and undeletion of a record.
Custom Platform Events – Custom platform events are sObjects, similar to custom objects and are defined in the same way you define a custom object. They are used to publish custom events using through Apex, a process, a flow, or an API.
We will be using each of both types for this project:
Change Data Capture Events – To communicate Opportunity and Case record data to the Dashboard
Custom Platform Event – To communicate Chatter Announcements to the Dashboard. This custom event will be published via a process built with Process Builder
Setup CDC Events for Opportunity Object
In your Salesforce Org, navigate to Setup
Enter ‘Change Data Capture’ in the Quick Find box
Select Change Data Capture under Integrations
In Available Entities, Select Opportunity (Opportunity) and click the > arrow to add it to Selected Entities
In Available Entities, Select Case (Case) and click the > arrow to add it to Selected Entities
Click Save
Create Custom Platform Event To Communicate Chatter Announcements
In your Salesforce Org, navigate to Setup
Enter ‘Platform Events’ in the Quick Find box
Select Platform Events under Integrations
On the Platform Events Page, click the New Platform Event button
Create Platform Event with the following Events
Label: Chatter To TV Dashboard
Plural Label: Chatter To TV Dashboard
Object Name: Chatter_To_TV_Dashboard
Description: Communicate Chatter Announcements to TV Dashboard
Publish Behaviour: Publish Immediately
On the Chatter To TV Dashboard platform event page, click New in Custom Fields & Relationships
Select Text Area (Long) as the field data type & Click Next
Set the following values:
Field Label: Message
Length: 131,072
# Visible Lines: 3
Field Name: Message
Description: The Chatter Announcement Content
Click Save
Create process to Communicate Chatter Announcements
Create a New Process on the Feed Item Object
In your Salesforce Org, navigate to Setup
Enter ‘Process Builder’ in the Quick Find box
Select Process Builder under Process Automation
Click New
For Process Name, type ‘Send Chatter Announcement to TV Dashboard’
For The process starts when, select A record changes, and click Save
Click + Add Object
In the right window, select Feed Item from the Object drop-down list
For Start the process select when a record is created or edited
Click Save
Add Process Criteria
Click + Add Criteria
For Criteria Name, type ‘Check If Announcement’
For Criteria for Executing Actions, keep it set to Conditions are met
For Set Conditions, click Find a field…, select Feed Item Type and click Choose.
Set Operator to Equals, Type to Picklist, and Value to Advanced Text Post
For Conditions, keep it set to All of the conditions are met (AND)
Click Save
Add Process Action
Under the Immediate Actions box, click + Add Action
In the Action Type drop-down list, select Create a Record
For Action Name, type ‘Create Platform Event‘
For Record Type, select Chatter To TV Dashboard (the platform event that we had created)
Under Set Field Values, click Find a field…, then select Message
For Type, select Field Reference
For Value, click Find a field…, then select Body field of the FeedItem and click Choose
Click Save
Click Activate and then click Confirm
That is it! We have setup our Salesforce Environment successfully. Now, Let’s move on to the Raspberry Pi setup!
This blog post is part 2 of the blog post series on Build TV Dashboards with Salesforce Data, Platform Events & a Raspberry Pi.
For the ease of readability & structure I’ve divided this tutorial into a series of blog posts. This is the first one in the series and here are the links to the other two:
Part 2 – Salesforce Setup (you are on this now)
Resources (Trailhead, Trailhead, Trailhead)
Here are some amazing resources from Trailhead on the concepts that we are using in this project.
Platform Events Basics
https://trailhead.salesforce.com/en/content/learn/modules/platform_events_basics
Change Data Capture Basics
https://trailhead.salesforce.com/en/content/learn/modules/change-data-capture
Quick Start: Process Builder
https://trailhead.salesforce.com/en/content/learn/projects/quickstart-process-builder
Lightning Flow
https://trailhead.salesforce.com/en/content/learn/modules/business_process_automation
Lightning Web Components Open Source
Lightning Design System Basics
https://trailhead.salesforce.com/en/content/learn/modules/lightning-design-system-basics