Month: April 2021

Add fields to Salesforce Flow (Summer ’21)

Coming in the Salesforce Summer ’21 release is a new way to add fields to a flow screen element.

Instead of manually configuring and adding new fields to a Screen element, you can use the new Fields selector.

Now, before you get too excited about this there are two conditions:

  • You need to be using Summer ’21 edition
  • You need to have a variable representing a single record

This is a beta feature in Salesforce Summer ’21 which is available in pre-release orgs now, in preview orgs from May 7 and in your production orgs between May 15 and June 12.

Being a beta feature means you can test it in your sandboxes but it is not recommended for production use.

The second condition is having a variable that represents a single record. Let’s take a look at what this means:

Here is a simple screen flow that has a Get Records element:

The element is configured to only get the first record (so it meets the condition of a variable containing a single record). It does this by passing in recordId (the ID of the page we started this flow from).

Next, we add a Screen element:

The new Fields (beta) function is now available:

Select the Fields (Beta) tab (1) and then in the Record Variable field (2), specify the record variable that contains the fields we want:

The available fields are now displayed, separated into Required Fields and the regular fields:

The available fields can now be dragged across to the screen element. No longer do you have to manually create and configure new fields!

You will need to add an Update or Create records element to update or create new records – but at least the creation of new fields on a screen is simplified.

Open Opportunities/Cases list view in Flow

I had a challenge today at work. I needed to display a list of Open Opportunities and Open Cases for any given Account. The aim was to give an account manager a quick view of what Opportunities and Cases were currently in progress for the Account before they touched base with their key contact.

At first, I thought I could just use a related list, but I only wanted the open opportunities and cases, not the whole lot. I also wanted to only show five (5) records of each so it did not take up too much space on the page. There was no way I could find to filter the related list view and only show a maximum of five records.

I’m not a developer, I think I am allergic to Apex but I’m pretty confident with my Salesforce flow skills. So I started thinking, I could do a get records and only get the open opportunities/cases that are related to this Account. The next problem was how to display them in a compact format and finally how to display a maximum of five records?

That’s where UnofficialSF.com comes to the rescue and Eric Smith’s datatable flow component. This allows me to display the records in a table format and also limit the dislay to the first five records.

Here is the full description of the flow for the Opportunity related list, the case flow is almost identical but uses the case object.

First step is to create a new variable: recordId, of type text with Available for Input checked (so we can pass the account ID into the flow from the account page).

Create a New Variable

Get the Open Opportunities related to the Account (recordId)

Add an Assignment Element to Count how many opportunities were returned

Install the datatable component

Before you can use the datatable component you need to install it (and it’s two dependencies from UnofficialSF.com)

Start the install here: https://unofficialsf.com/datatable-lightning-web-component-for-flow-screens-2/

Next, add a screen element and insert the datatable component

Note: Turn off the header/footer as they are not needed,


Configuring the datatable component:

Follow the settings here, you can experiment with changing them later.


Continue with the settings further down the page:


Return to the middle of the page and click the button Configure Columns:


Select the columns you want:

Change the width settings, keeping the total width to 552 (to fit a 1/3 page right column).


Save and activate the flow.


Edit the Lightning Record Page for the Account

Add a Flow component(1).

Select the new Open Opportunities flow (2), select single column (3).

Pass across the {!Record.Id} from the Account page into the flow (4).

Add a Component Visibility filter to only show the component if there are open Opportunities to display (5).

Save and activate the Lightning Page.

Open an Account record that has Open Opportunities to display the result.


Celebrate!

If you want Open cases as well, create a second flow with most of the same settings but select the case object and case fields.