Salesforce: The Power of the Screen Flow Data Table

tl;dr: Salesforce’s screen flows can be used to surface data onto a parent record from children further down the chain. Dynamic filtering and display options give us tools to solve complex use cases without resorting to code.

I work with a lot of managed packages in Salesforce and they tend to make heavy use of Junction Objects. While this is a smart (and necessary) way to create many-to-many relationships, it can be challenging to surface data that the users need to see.

One option is to embed filtered reports either directly into a lightning page (via a report chart), or by using a custom link or button to apply the filter.

Another option is to use a nifty little Salesforce feature: Data Tables via Screen Flows.

Context: Screen Flows

In the olden days when I learned Salesforce, screen-flows were primarily for guiding users to input data to create records. You could have decisions behind each step, directing users down different paths depending on the data they entered on screen.

They were useful, but took time and effort to design well. And when Salesforce released the Paths feature, allowing us to provide guidance and field-level validations as a record progressed through a cycle, I stopped thinking too much about screen-flows.

Until I came upon a very specific problem: I needed to display the billing rates for each project on the project page

The Challenge

Salesforce related lists show records that are directly linked (via a lookup) to the record you are viewing. On Lightning pages, you can use parent records and select related lists from there. But as with all things Salesforce ‘you can look up, but you can’t look down’1.

Report charts can be useful in some instances, but when you can’t show tabulated data. And the rates in use on a project are definitely tabulated data – sometimes more than 10 rows of them,

Part of the appeal of Salesforce is the ‘clicks not code’ approach, and while I could have put all the data into a lightning component, this didn’t feel fair on the client, who might need to make amendments in the coming years.

The Solution – Data Tables in Screen Flow

Historically, I had always thought of screen flows as requiring user interaction – but this is no longer the case! You can, in fact, write a simple flow with a ‘get’ and then a screen to display the results. And if you want, you can remove any ability to interact with those results and call it a day.

This is a super flexible solution that I have used on both record pages and stand-alone lightning pages, because the flow can respond dynamically to both the user and the object (in the case of a record page).

Worked Example – Show Contacts on a Project Page

Scenario: The Project Manager needs to see all the customer contacts for their project in one space. However, there are other contact records that the company needs to keep in their CRM. The Operations Manager is keen to have a single source of truth for all contacts.

Solution: We will use the Contacts records associated with the Account and make sure that the contacts related to the Project can be clearly identified. For this, we will give them the Department of Professional Services.

Since Projects are associated with an Account, we can use a Screen Flow to display the specific contacts and the fields we need to use to contact them as part of our project.

Hint: Using a free-text field (Department) as our filter works in our example, but a custom check-box would be a more resilient solution. Note that if one account has multiple projects, the same contacts will be displayed for each of the account’s projects.

Step by Step – Build The Flow

Here’s how you create the screen flow:

From Setup > Flows create a new flow and choose Screen Flow

The screen flow is not triggered from a record, so you don’t have to set any entry conditions:

But we need to work from our project record, so we are going to create a variable and store the project Id in there (we’ll populate it in a later step, when we add the flow to our project lightning page):

Our variable uses the Data Type Record, because we want to be able to find the account field from the project. We want to make sure it is available for input outside the flow, so we can pass the record Id into it from the lightning page.

Once we have this variable set up, we need to use a Get action to get the contacts that we want to display:

We can then use or Project variable to get the account that we to find contacts for:

Because our variable is a record, we can go through that record to find related records (in this case, our account).

We’re also going to use a filter here and only return Contacts where the Department is “Professional Services”.

We want to ensure that we store all the records that meet this criteria, and we can let Salesforce automatically store all the fields:

Once we have the records, we use a screen element to display them:

Within our Screen, we need to chose the Data Table option so we can display our data:

From here, we can choose a suitable title, and then select our collection from the Get Records in the previous step:

Once we have the collection, we need to choose which fields we want to display:

Since we just want to display the data, we are not going to allow users to modify the data from the project screen. I also removed the footer, so there are no buttons to confuse the users.

Once you have all your columns in place and have named the screen, save the flow and test it before we activate it. Once a flow has been activated, you need to create a new version to make edits, so we want to test the flow before we do that.

Step by Step – Test The Flow

We can test screen flows using the debug button.

For our flow, we need to set a Project Id so we can mimic the behaviour we will see on the project Lightning page:

Clicking on Run will run the flow so you can see the outputs and confirm they meet your needs:

This is a good opportunity to check any filtering you have in your Get Records, and make sure the flow picks up any related records (such as the Account) correctly.

Once we’re happy that the flow is working how we want, we need to Activate the flow before we can use it on a Lightning Page.

Step by Step – Add to the Lightning Page

Now that our flow is active, we can embed it into the project lightning page.

Navigate to a project and click on Edit Page (or go from the object itself through the Lightning Page option).

For this component, I added a new tab to my accordian specifically to hold my screen flow.

Add the flow component, and choose your flow by name. Only screenflows which are active will show up here.

Because we need to pass the record Id into the flow, we need to make sure the ‘Pass all field values from the record into the flow variable’ box is checked under the name of our variable.

This is because our variable is of the type record, so Salesforce will collect the whole record. If your screen flow is more complex and requires more inputs, they will be shown here and you can choose how to populate them.

Don’t forget to save your page changes and make sure your page layout is active.

Step by Step – The Output

Once the page is saved and active, we should see the flow in action on our page:

This is a clean and simple view for our Project users, without changing or compromising anything about the accounts or contacts in CRM:

We can see that the filter has been applied and only relevant contacts and their details are displayed in the screen flow.

Considerations Before Go Live

In order to run screen flows, users need to be enabled as ‘flow users’.

Further Use Cases

The worked example is deliberately simple, and a similar result could have been achieved via a related list from the Account. But the use cases I tend to encounter (often associated with managed packages with proprietary object models) are:

  1. Displaying related data that isn’t usually exposed in its raw form – this could be underlying analytics data that we don’t want users to click into or amend
  2. Displaying informative data on non-record Lighting pages – a classic example is showing all internal Projects with a description of when to report time against them on a time entry page
  3. Highlighting specific records on landing pages while still allowing the user to curate their own list views on the actual object – such as showing projects associated with accounts where renewals are due soon

While most of these needs can be met with other features, the screen flow is a good option to keep in our pocket and allows us to have flexible, dynamic filtering and control over outputs.

  1. Actually, on a lightning page, you can sometimes get around this by grabbing a related list from your junction object in the options – but I still think screen flows are cleaner. ↩︎

Comments

Leave a Reply