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.

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

  1. In your Salesforce Org, navigate to Setup
  2. Enter ‘Change Data Capture’ in the Quick Find box
  3. Select Change Data Capture under Integrations
  4. In Available Entities, Select Opportunity (Opportunity) and click the > arrow to add it to Selected Entities
  5. In Available Entities, Select Case (Case) and click the > arrow to add it to Selected Entities
  6. Click Save

Change Data Capture (CDC) Setup

Create Custom Platform Event To Communicate Chatter Announcements

  1. In your Salesforce Org, navigate to Setup
  2. Enter ‘Platform Events’ in the Quick Find box
  3. Select Platform Events under Integrations
  4. On the Platform Events Page, click the New Platform Event button
  5. 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
  6. On the Chatter To TV Dashboard platform event page, click New in Custom Fields & Relationships
  7. Select Text Area (Long) as the field data type & Click Next
  8. Set the following values:
    • Field Label: Message
    • Length: 131,072
    • # Visible Lines: 3
    • Field Name: Message
    • Description: The Chatter Announcement Content
  9. Click Save

Platform Events Setup

Create process to Communicate Chatter Announcements

Create a New Process on the Feed Item Object

  1. In your Salesforce Org, navigate to Setup
  2. Enter ‘Process Builder’ in the Quick Find box
  3. Select Process Builder under Process Automation
  4. Click New
  5. For Process Name, type ‘Send Chatter Announcement to TV Dashboard’
  6. For The process starts when, select A record changes, and click Save
  7. Click + Add Object
  8. In the right window, select Feed Item from the Object drop-down list
  9. For Start the process select when a record is created or edited
  10. Click Save

Process Builder Step 1

Add Process Criteria

  1. Click + Add Criteria
  2. For Criteria Name, type ‘Check If Announcement’
  3. For Criteria for Executing Actions, keep it set to Conditions are met
  4. For Set Conditions, click Find a field…, select Feed Item Type and click Choose.
  5. Set Operator to Equals, Type to Picklist, and Value to Advanced Text Post
  6. For Conditions, keep it set to All of the conditions are met (AND)
  7. Click Save

Process Builder Step 2

Add Process Action

  1. Under the Immediate Actions box, click + Add Action
  2. In the Action Type drop-down list, select Create a Record
  3. For Action Name, type ‘Create Platform Event
  4. For Record Type, select Chatter To TV Dashboard (the platform event that we had created)
  5. Under Set Field Values, click Find a field…, then select Message
  6. For Type, select Field Reference
  7. For Value, click Find a field…, then select Body field of the FeedItem and click Choose
  8. Click Save
  9. Click Activate and then click Confirm

Process Builder Step 3

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.
Here is a link to the next and final Part 3 post > Part 3 – Raspberry Pi Setup

Resources (Trailhead, Trailhead, Trailhead)

Here are some amazing resources from Trailhead on the concepts that we are using in this project.

Leave a Reply

Your email address will not be published.