I want to create a unique account(unique account name) collection variable in Salesforce flow using the get record element, we have a duplicate account name(multiple accounts with the same name) and I want to skip the same name account in my collection variable.

1 Answer 1


Creating Unique collections requires using advanced programming concepts like using Sets and Maps. These are not today supported out-of-box in Flows.

There is an idea for this on IdeaExchange. Consider upvoting!

However, the community has done some open source work that you can adopt and experiment with.

There is a component here that you can install as an unmanaged package.

The apex code for this is pretty simple and open-sourced as well and easy to understand if you are familiar with apex.

global with sharing class DedupeRecordCollection {

global static List<FlowResponse> dedupe(List<FlowRequest> requests) {
    List<FlowResponse> flowResponses = new List<FlowResponse>();
    for (FlowRequest request : requests) {
        FlowResponse flowResponse = new FlowResponse();
        flowResponse.outputRecordCollection = getUniqueSObjectCollection(request);
    return flowResponses;

private static List<SObject> getUniqueSObjectCollection(FlowRequest request) {
    Map<String, SObject> sobjectMap = new Map<String, SObject>();
    for (SObject record : request.inputRecordCollection) {
        try {
            String fieldValue = String.valueOf(record.get(request.fieldToDedupeOn));
            if(!sobjectMap.containsKey(fieldValue)) {
                sobjectMap.put(fieldValue, record);
        } catch(SObjectException e) {
    return sobjectMap.values();

global class FlowRequest {

    global List<SObject> inputRecordCollection;
    global String fieldToDedupeOn;

global class FlowResponse {

    public FlowResponse() {
        outputRecordCollection = new List<SObject>();

    global List<SObject> outputRecordCollection;


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.