Screen Flow How to Unselect the Blue Bar
Last Updated on June 25, 2022 by
Big Idea or Enduring Question:
- How do you remove the duplicates from the record collection variables or collection variables in flow without writing code?
Objectives:
After reading this blog, you'll be able to:
- Understand different flow operators in assignment element
- Understand how to remove common records b/w record collection variables (1 & 2) and store remaining records of record collection variable (1)
- Understand how to remove uncommon records b/w record collection variables (1 & 2) and store duplicate records in record collection variable (1)
- Understand how to remove duplicate records from record collection variables (1 & 2) and only store unique records
- Understand how to remove duplicate records from both (1 &2) the record collection variables and only store remaining records across both record collection variable
- and much more
One of the very common questions people ask me is how to remove the duplicate records if I have two or more record collection variables. This article will go through various use cases to understand how to remove the duplicates from the record collection variables.
Prerequisite
Before discussing the different use cases, let's pause here and spend some time setting up the data.
Go ahead and set up the test data as per the below screenshot. Setting the test data makes it easier to understand the duplicate record removal from the record collection variables instead of spending time validating outcomes.
The next step is to set up a basic flow to have two record collection variables of contacts with different query parameters.
Step 1: Define Flow Properties
- Click Setup .
- In the Quick Find box, type Flows .
- Select Flows then click on the New Flow .
- Select the Screen Flow option and click on Next and configure the flow as follows:
- How do you want to start building : Freeform
- It will open the flow designer for you.
Step 2: Adding a Get Record Element to Find Contacts where Department = IT
The next step is to use the Get Records element to find the contacts whose department is IT.
- On Flow Designer, click on the +icon and select the Get Records element.
- Enter a name in the Label field; the API Name will auto-populate.
- Select the Contact object from the dropdown list.
- Select All Conditions Are Met (AND) .
- Set Filter Conditions
- Row 1:
- Field: Department
- Operator: Equals
- Value: IT
- Row 1:
- How Many Records to Store:
- select All record
- How to Store Record Data:
- Choose the option to Automatically store all fields .
- Click Done .
Step 3: Adding a Get Record Element to Find Contacts where Lead Source = Web
The next step is to use the Get Records element to find the contacts whose Lead Source is Web.
- On Flow Designer, click on the +icon and select the Get Records element.
- Enter a name in the Label field; the API Name will auto-populate.
- Select the Contact object from the dropdown list.
- Select All Conditions Are Met (AND) .
- Set Filter Conditions
- Row 1:
- Field: Lead Source
- Operator: Equals
- Value: Web
- Row 1:
- How Many Records to Store:
- select All record
- How to Store Record Data:
- Choose the option to Automatically store all fields .
- Click Done .
In the end, your Flow will look like the following screenshot:
Now two record collection variables hold the following data.
Record Collection Variable (IT Dept. Contacts) – 1
RecordId | Last Name |
003B000000KI9sxIAD | 2 |
003B000000KI9t2IAD | 3 |
003B000000KI9t7IAD | 4 |
003B000000KI9tCIAT | 5 |
Record Collection Variable (IT Dept. Contacts) – 2
RecordId | Last Name |
003B000000KI9snIAD | 1 |
003B000000KI9sxIAD | 2 |
003B000000KI9t2IAD | 3 |
003B000000KI9tHIAT | 6 |
003B000000KI9tMIAT | 7 |
Business Use case I
Jason Herris a Solution Architect at Gurukul on Cloud (GoC). He wants to understand how to remove uncommon records b/w record collection variables (1 & 2) and store remaining records of record collection variable (1).
At the end, he is expecting the following records in Record Collection Variable (IT Dept. Contacts) .
Record Collection Variable (IT Dept. Contacts)
RecordId | Last Name |
003B000000KI9t7IAD | 4 |
003B000000KI9tCIAT | 5 |
A solution for the above business requirement
This is a very common scenario for Salesforce Flow. Let's try to understand Remove All operator in assignment element.
Operator | Description | Supported Data Types | Example |
Remove All | All instances of Value are removed from the collection in Variable. | Collection of the same data type or object type Variable of the same data type or record variable of the same object type For text collections only:
| Before the Assignment:
Assignment: After the Assignment: |
Using Assignment Element to Remove All
The next step is to remove common records b/w record collection variables (1 & 2) and store remaining records of record collection variable (1). We will use the Assignment element
- On Flow Designer, click on the +icon and select the Assignment element.
- Enter a name in the Label field; theAPI Name will auto-populate.
- Set Variable Value
- Row 1:
- Field: {!IT_Dept_Contacts}
- Operator: Remove All
- Value: {!Web_Sourced_Contacts}
- Field: {!IT_Dept_Contacts}
- Row 1:
- Click Done .
Now your Flow will look like the following screenshot:
Almost there! Once everything looks good, click the Save button.
Let's debug the flow to validate the outcome and match it with the expected outcome:
Business Use case II
Jason Herrwas very happy with his learnings so far. He wants to learn how to remove uncommon records b/w record collection variables (1 & 2) and store duplicate records in record collection variable (1)
At the end, he is expecting the following records in Record Collection Variable (IT Dept. Contacts) .
Record Collection Variable (IT Dept. Contacts)
RecordId | Last Name |
003B000000KI9sxIAD | 2 |
003B000000KI9t2IAD | 3 |
A solution for the above business requirement
This is a very common scenario for Salesforce Flow. Let's try to understand Remove Uncommon operator in assignment element.
Operator | Description | Supported Data Types | Example |
Remove Uncommon | The items in the Value collection are found within the Variable collection. The found items are kept, and all other items are removed from the collection in Variable. | Collection of the same data type or object type | Before the Assignment:
Assignment: After the Assignment: |
Update Assignment Element to Remove Uncommon
The next step is to remove uncommon records b/w record collection variables (1 & 2) and store duplicate records in record collection variable (1). We will use the Assignment element
- Update the Assignment element.
- Set Variable Value
- Row 1:
- Field: {!IT_Dept_Contacts}
- Operator: Remove Uncommon
- Value: {!Web_Sourced_Contacts}
- Field: {!IT_Dept_Contacts}
- Row 1:
- Click Done .
Almost there! Once everything looks good, click the Save button.
Let's debug the flow to validate the outcome and match it with the expected outcome:
Business Use case III
Jason Herrwants to learn how to remove duplicate records from record collection variables (1 & 2) and only store unique records.
At the end, he is expecting the following records in Record Collection Variable (IT Dept. Contacts) .
Record Collection Variable (IT Dept. Contacts)
RecordId | Last Name |
003B000000KI9snIAD | 1 |
003B000000KI9sxIAD | 2 |
003B000000KI9t2IAD | 3 |
003B000000KI9t7IAD | 4 |
003B000000KI9tCIAT | 5 |
003B000000KI9tHIAT | 6 |
003B000000KI9tMIAT | 7 |
A solution for the above business requirement
This is a very common scenario for Salesforce Flow. Perform the steps below:
Update Assignment Element to Keep Unique Records
The next step is to remove duplicate records from record collection variables (1 & 2) and only store unique records. We will use the Assignment element
- Update the Assignment element.
- Set Variable Value
- Row 1 :
- Field: {!IT_Dept_Contacts}
- Operator: Remove All
- Value: {!Web_Sourced_Contacts}
- Field: {!IT_Dept_Contacts}
- Click Add Assignment
- Row 2 :
- Field: {!IT_Dept_Contacts}
- Operator: Add
- Value: {!Web_Sourced_Contacts}
- Field: {!IT_Dept_Contacts}
- Row 1 :
- Click Done .
Almost there! Once everything looks good, click the Save button.
Let's debug the flow to validate the outcome and match it with the expected outcome:
Business Use case IV
Jason Herrwants to learn how to remove duplicate records from both (1 &2) the record collection variables and only store remaining records across both record collection variable.
At the end, he is expecting the following records in Record Collection Variable (IT Dept. Contacts) .
Record Collection Variable (IT Dept. Contacts)
RecordId | Last Name |
003B000000KI9snIAD | 1 |
003B000000KI9t7IAD | 4 |
003B000000KI9tCIAT | 5 |
003B000000KI9tHIAT | 6 |
003B000000KI9tMIAT | 7 |
A solution for the above business requirement
This is a very common scenario for Salesforce Flow. Perform the steps below:
Salesforce Flow – Create Collection Variable to Store Contacts
- Under Toolbox , select Manager, then click New Resource to store multiple contact records.
- Input the following information:
- Resource Type: Variable
- API Name: varR_ContactsPlaceholder
- Data Type: Record
- Object: Contact
- Click the Yes checkbox – Allow multiple values (collection)
- Check Available for Input
- Check Available for Output
- Click Done .
Update Assignment Element to Keep Unique Records
The next step is to remove common records from both (1 &2) the record collection variables and only store remaining records across both record collection variable. We will use the Assignment element
- Update the Assignment element.
- Set Variable Value
- Row 1 :
- Field: {!varR_ContactsPlaceholder}
- Operator: Add
- Value: {!IT_Dept_Contacts}
- Field: {!varR_ContactsPlaceholder}
- Click Add Assignment
- Row 2 :
- Field: {!IT_Dept_Contacts}
- Operator: Add
- Value: {!Web_Sourced_Contacts}
- Field: {!IT_Dept_Contacts}
- Click Add Assignment
- Row 3 :
- Field: {!varR_ContactsPlaceholder}
- Operator: Remove Uncommon
- Value: {!Web_Sourced_Contacts}
- Field: {!varR_ContactsPlaceholder}
- Click Add Assignment
- Row 4 :
- Field: {!IT_Dept_Contacts}
- Operator: Remove All
- Value: {!varR_ContactsPlaceholder}
- Field: {!IT_Dept_Contacts}
- Row 1 :
- Click Done .
Almost there! Once everything looks good, click the Save button.
Let's debug the flow to validate the outcome and match it with the expected outcome:
Formative Assessment:
I want to hear from you!
What is one thing you learned from this post? How do you envision applying this new knowledge in the real world? Feel free to share in the comments below.
Source: https://automationchampion.com/2022/06/07/remove-duplicates-from-record-collection-variables-in-a-flow-2/
0 Response to "Screen Flow How to Unselect the Blue Bar"
Post a Comment