Using Flow Builder to Update Selected List View Records

Using Flow Builder to Update Selected List View Records


Did you ever wonder how you can declaratively pass the IDs of selected records to Flow Builder from a list view?

Well, this article may be what you are looking for!

Join Chuck Morris, a Salesforce Admin who works at KarateKit.COM, who has just created this process without coding.

Chuck has recently received a new requirement: Lightning Experience Users want to be able to close one or more Case records by selecting these records within a list view.

In order to make it happen, Chuck needed to find a solution. Initially, he was about to ask his developer to develop it. A moment before he made the call, he remembered a line he had heard many times before: "Use the force wisely, Chuck...".

After sleeping on the requirement, he came up with a solution. His solution is based on Flow Builder and a Flow Action called 'Get/Search with APEX' created by GravityLab.

> Make sure you install the Flow Action before you start building the process (Sandbox | Production)

Update (JUL.08.20): Following a suggestion I've received, there is no need for the Apex Action. Please review the full explanation at the end of the article. The changes I've made are relevant to both the Loop and the Assignment Elements.


1. Creating a Flow

In Lightning, go to Setup | Process Automation | Flows

A. Creating a new Flow

  1. In the Flows page, click on the 'New Flow' button.
No alt text provided for this image

2. In the new window, select 'Autolaunched Flow'.

3. Click on the 'Create' button.

No alt text provided for this image


B. Defining the Flow Trigger

Double click on the 'Start' element and define as follows:

  1. Under the 'What Launches the Flow' option, select 'Users of apps-no flow trigger'.
  2. When you're finished, click 'Done'
No alt text provided for this image


C. Create the following variables:

Collection Variable:

  • ids - a Text Collection that will hold the selected Case record IDs. Note that the IDs will be automatically passed to the Flow. No additional steps are required.
No alt text provided for this image


Record (Single) Variable:

  • SO_Cases - a record variable for each of the Case records
No alt text provided for this image


Record Collection Variables

  • SOC_Cases - the Collection is used for updating the Case records
No alt text provided for this image
  • SOC_CaseCollectionOutput - a record collection variable to hold the case records that will be retrieved by an Apex Action.
No alt text provided for this image


D. Adding an Apex Action

Drag the 'Action' element to the canvas and define the following information:

No alt text provided for this image


Under the 'Set Input Values', define the following information:

No alt text provided for this image

> In this section, we've defined the action to return the Case Id and the Status of each record. Under the 'List Of Ids' we have added the 'ids' collection variable.

Under the 'Store Output Values', define the following information:

No alt text provided for this image

> Make sure you select the 'Manually assign variables (advanced)' and add the 'SOC_CaseCollectionOutput' record collection variable under the 'outputCollection'.

Now you can connect the Start element to the Action element you just created:

No alt text provided for this image




> Make sure you save your flow.


E. Creating a Loop element

Drag the 'Loop' element to the canvas and provide it with the following information:

No alt text provided for this image

When you're finished, click 'Done'.

Connect the Action element to the Loop element you just created and click 'Done':

No alt text provided for this image







F. Creating an Assignment element

Drag an 'Assignment' element to the canvas and provide it with the following information:

No alt text provided for this image

When you're finished, click 'Done'.

Connect the Loop element to the Assignment element you just created and click on the 'Done' button in the new screen that will appear:

No alt text provided for this image

The flow will look as follows:

No alt text provided for this image







G. Creating a second Assignment Element

Drag another 'Assignment' element to the canvas and provide it with the following information:

No alt text provided for this image

When you're finished, click on 'Done'.

Connect the first Assignment element to the Assignment element you just created, and then connect the second Assignment element back to the Loop element:

No alt text provided for this image









> Make sure you save your flow occasionally. Just in case...


H. Creating an Update Records Element

Drag the 'Update Records' element to the canvas and provide it with the following information:

No alt text provided for this image

When you're finished, click 'Done'.

Connect the Loop element to the Update Records element you just created - The Flow is ready:

No alt text provided for this image









> Make sure you click on the 'Save' button BEFORE activating the flow.


I. Activating the Flow

After saving the flow, click on the 'Activate' button located at the top-right side of the screen:

No alt text provided for this image


2. Creating a Custom Button

In Lightning, go to Setup | Objects and Fields | Object Manager

In the Object Manager, search for the Case object and select it.

A. Creating a List Button

In the left pane, click on 'Buttons, Links, and Actions' (A). Then, click on the 'New Button or Link' button located to the right (B).

No alt text provided for this image


B. Defining the List Button

  1. Provide the button with a meaningful name and a description.
  2. Under the 'Display Type', select 'List Button'.
  3. Under the 'Behavior', select 'Display in existing window without sidebar or header'
  4. Under the 'Content Source', select 'URL'
  5. In the large text box, paste the following URL (You'll have to change the List View Id to your own Id):
/flow/Closing_Cases_from_Related_List_of_List_Views_Flow?retURL=/lightning/o/Case/list?filterName=00B0Y000002xMTkUAM

6. When you're finished, click 'Done'


Let's break that down:

  • The following URL defines to which flow we are calling
/flow/Closing_Cases_from_Related_List_of_List_Views_Flow

You can copy the flow’s URL from the Flow Detail page:

No alt text provided for this image
  • After the question mark, add the following URL.
retURL=/lightning/o/Case/list?filterName=00B0Y000002xMTkUAM

This will define the Salesforce page our users will be redirected once the update is finished. In our demonstration, we are redirecting them to a specific Case List View (again, use your own list view Id).


3. Adding the Custom Button to the Search Layout

In Lightning, go to Setup | Objects and Fields | Object Manager

In the Object Manager, search for the Case object and select it.

A. Selecting the Search Layout

In the left pane, click on 'Search Layouts for Salesforce Classic'. Yes, I know it might be strange that I didn't choose the 'Search Layouts' option. For some reason, the custom button appeared in my list view only when I added it to the Salesforce Classic search layout. If you know the reason why, please let me know, I will be more than happy to update my article.

No alt text provided for this image

B. Adding the Custom Button to the List View layout

Drag the 'Close Cases' custom button from the 'Available Buttons' to the 'Selected Buttons' and click 'Save'.

No alt text provided for this image












The button is now added to the list view:

No alt text provided for this image

Update (JUL.08.2020):

Following a suggestion I've received from Alex Rabinovich I was able to create the process without the Apex Action. Alex suggested adding the 'ids' record collection variable into the loop under the 'Collection Variable' and then to add a (single) variable under the 'Loop Variable'.

This is how the Loop element would look like:

No alt text provided for this image








Now, update the Assignment element as follows:

No alt text provided for this image

That's it - everything else stays the same.

This is why I love the Salesforce platform so much - every day I can learn something new :)


The process is ready!


Watch the process in action:


A few important notes:

  1. Note that the 'ids' variable isn't documented in Salesforce documentation, so please use it in your own discretion.
  2. This process can also be used with Enhanced Lists!
  3. Note that starting Summer '20 release the Loop Variable is automatically created.
  4. Make sure you test the process in your sandbox environment before deploying it to your production environment.
  5. There are several ways to perform this business scenario, so make sure your solution is based on your business requirements and the tools that are available to you as for now.


If you have questions or anything to add - I would love to hear from you. Just write your comments below :)



David Roberts

If it’s not Virtual Worlds - It’s still not VR!

3 å¹´

Tried this on a Contact list view. I couldn't get the selected list through to the flow despite trying the 'ids' tip. I used a visual force page as described by Vibhor at https://www.accidentalcodersf.com/2020/07/use-flows-from-list-views-salesforce.html

Gidi, Do you have the complete example for same use case without using Apex action?

赞
回复
Asif Qureshi

Salesforce Developer || 3X Salesforce Certified

3 å¹´

is there any way to pass ListViewId dynamically to retURL?

赞
回复
Aharon Y.

?? 5x Salesforce Certified | External Consultant at CyberArk

4 å¹´

Genius, Its exactly what i was looking for for a issue that i have

Cristalyn Marin

Salesforce Administrator | Project Manager | Revenue and Volume Operations Analyst | Salesforce Manager | Business Analyst

4 å¹´

Hi Gidi Abramovich Is it possible with Flow Builder to update an object record using data from reports?

赞
回复

要查看或添加评论,请登录

Gidi Abramovich的更多文章

社区洞察

其他会员也浏览了