How to Remove Duplicates Using Assignment Operators in Flow : Yumi Ibrahimzade

How to Remove Duplicates Using Assignment Operators in Flow
by: Yumi Ibrahimzade
blow post content copied from  Salesforce Time
click here to view original post



### Summary In Flow, a collection variable is a list that can hold multiple values of the same type. Sometimes, you may have duplicate items in this collection, which can clutter your data. This guide explains how to remove duplicates and create a unique collection using specific operators. To eliminate duplicates, you can use the **Remove All** and **Add** collection assignment operators. This method only works for exact duplicates, meaning items that are completely identical. For instance, two different Contact records with the same email address are not considered duplicates. To create a collection of unique email addresses from Contact records, follow these steps: 1. Use a **Get Records** element to retrieve the relevant Contact records. 2. Create a text collection to store the email addresses. 3. Instead of simply adding email addresses (which may include duplicates), use a **Loop** and **Assignment** elements. The **Remove All** operator will remove the current item from the collection, and then the **Add** operator will add it back, ensuring each email address is unique. This method effectively manages duplicates, resulting in a collection with unique email addresses. ### Additional Context This process is particularly useful in Salesforce environments where data integrity is crucial. By ensuring that collections contain only unique values, you can improve the efficiency of your data handling and reporting processes. ### Hashtags for SEO #Salesforce #Flow #DataManagement #RemoveDuplicates #UniqueCollection #EmailAddresses #SalesforceFlow #DataIntegrity #Automation #SalesforceTips


A collection variable in Flow is an ordered list that holds multiple values of the same data type. In some scenarios, the same item might appear more than once in the collection, leading to unnecessary duplicates. When this happens, you may want to filter out the duplicates and keep only the unique values. In this post, you will learn how to remove duplicates and build a unique collection using collection assignment operators in Flow.

Using the Remove All and Add Operators to Remove Duplicates

You can remove duplicates in Flow by using the Remove All and Add collection assignment operators. However, it's important to note that this method only works for exact duplicates. It means items that are completely identical.

For example, if you have two different Contact records with the same email address, they are still considered separate records and won't be treated as duplicates by this method. On the other hand, if you're combining two record collections and a specific record exists in both, this method will ensure that the record appears only once in the final collection.

Let's build a flow to build a text collection of email addresses of Contact records.

1- Add a Get Records element to get the Contact records that meet the criteria.

Get Contact Records

2- Create a text collection to store the email addresses.

We want to add email addresses to a text collection. If you simply use the Add operator, it will add all the email addresses, even if some are duplicates. This can result in duplicate items when multiple contacts share the same email address.

One of the most common ways to ensure that each item appears only once in a collection is by using a Decision element to check if the item already exists before adding it. However, there's a simpler method: using the Remove All operator. Here is how to achieve this.

Add Loop and Assignment elements to your Flow. Then, configure the Assignment element as follows:

Using the Collection Assignment Operators to Remove Duplicates

The Remove All operator removes the current item from the collection, and then the Add operator adds it back. This ensures that each item appears only once in the collection. This method works for record variables too.

End of the Flow

As you can see, there are 5 Contact records with 3 unique email addresses.

Remove Duplicates

The post How to Remove Duplicates Using Assignment Operators in Flow appeared first on Salesforce Time.


April 22, 2025 at 04:27PM
Click here for more details...

=============================
The original post is available in Salesforce Time by Yumi Ibrahimzade
this post has been published as it is through automation. Automation script brings all the top bloggers post under a single umbrella.
The purpose of this blog, Follow the top Salesforce bloggers and collect all blogs in a single place through automation.
============================

Salesforce