Configuration tutorial

Build a Live-Updating Datatable in Salesforce

This tutorial shows you how to create a datatable in Salesforce that automatically updates in real-time whenever related records are changed or created. We'll use Platform Events, a Trigger Flow, and a Screen Flow to achieve this.

1. Create a Platform Event

We need a way to signal when a record changes. Platform Events act like a message system, letting us broadcast these changes in real-time

  • Go to Setup and search for Platform Events.

  • Click New Platform Event.

  • Fill in the Label (e.g., "RecordChangeEvent"), Plural Label, and the API Name should auto-populate.

  • Set Publish Behavior to Publish After Commit.

  • Click Save.

2. Add a Field to the Platform Event

We'll include a field in our Platform Event to store the ID of the record that was changed. This helps us target updates to the correct row in our datatable later on

  • After saving, click New Field within the Platform Event.

  • Choose a suitable data type (e.g., Text for record IDs).

  • Fill in the Field Label (e.g., "RecordId") and the Field Name should auto-populate.

  • Click Next, set any required properties, and click Save.

  • This field will help filter updates to specific records if needed.

3. Create a Trigger Flow

This flow will automatically run whenever a record is created or updated. Its job is to send a Platform Event message when a change occurs. If needed, we can also add conditions to send messages only for specific changes.

  • Go to Setup and search for Flows.

  • Click New Flow and choose Record-Triggered Flow.

  • Configure the trigger:

    • Object: Select the object you want to monitor (e.g., Lead).

    • Trigger: Choose whether it should trigger on Create or Update.

    • Condition Requirements: Define any specific conditions for triggering the flow.

  • Add a Create Records element:

    • Label: Give it a suitable name (e.g., "Create Record Change Event").

    • Create a Record: Choose Manually for How to set record field values

    • Object: Select the Platform Event object you created (e.g., RecordChangeEvent__e).

    • Field Values: Set the fields to reflect the changes (e.g., set recordId to {!Record.Id}).

  • (Optional) Add a Decision Node:

    • If you only want to create the Platform Event under certain conditions, add a Decision element before the Create Records element.

    • Define your decision criteria.

  • Activate the flow by clicking Activate.

4. Create a Screen Flow

This is where we'll build the user interface with our live-updating datatable. The datatable will be configured to listen for the Platform Events we created earlier, so it can refresh itself automatically when it receives a message.

  • Go to Setup and search for Flows.

  • Click New Flow and choose Screen Flow.

  • Add a Screen element to the canvas.

  • Add a Data Table component to the screen.

  • Configure the Data Table:

    • Data Source: Set it to Query.

    • Object: Choose the object to display (e.g., Account).

  • Go to Advanced Options:

    • In Query Refresh Emp, specify the name of your Platform Event (e.g., RecordChangeEvent__e).

    • Key Field Name: If you want to refresh only certain records, specify the field name (e.g., recordId).

  • Save and activate the flow.

5. Deploy the Flow

Finally, we need to make our Screen Flow accessible to users. We can embed it in a Lightning page, an App Page, or even add it to the Utility Bar for easy access.

Now you have a datatable that updates in real-time whenever the specified records are changed, thanks to the power of Platform Events and Salesforce Flows.

Last updated