Skip to main content

I'm working on the third version I have of a Flow that creates related records from an Interaction. My first version just created the related records from a list that is created dynamically. The second version allows Users to pick and choose which of those records are being created. In this third version, I want to eliminate the ability to create records, if they currently exist.  

 

I've added this loop to go through the list  that creates the new records, to see if there are records associated with members of that list. I've even asked AI (which I was trying not to do), and every suggestion it gave, I have correct, or have corrected.   

Deduping Record Creation from a flow

 

I can obviously expound on any questions on elements in use, but can anyone see where this may be going wrong?   

 

#Flownatics @Salesforce Flow Automation #Salesforce Developer #Architects

3 respuestas
  1. 8 mar, 16:55

    Looking at your Flow deduplication logic, I can see a few potential issues that might be causing problems. Let me help you troubleshoot this.

    Common Issues with Flow Deduplication Patterns

    1. Get Records Element Configuration

    The most common issue is how the Get Records element filters against your collection. When checking if records exist, ensure:

    • Filter Logic: Your Get Records should filter where a field (like a lookup or external ID) equals {!loopVariable.SomeIdentifier}
    • Store Output: Make sure "Automatically store all fields" is selected, or explicitly select the fields you need
    • How Many Records: Set to "All records" if you expect multiple matches, or "Only the first record" if checking for existence

    2. Decision Element Logic

    After your Get Records, your Decision should check:

    • Condition: {!GetRecordsVariable} Is Null = {!$GlobalConstant.True} (record doesn't exist, safe to create)
    • OR: Check if the collection from Get Records has a count of 0

    3. Loop Variable Reference

    Make sure you're correctly referencing the current item in your loop when filtering the Get Records. The syntax should be:

    • {!currentItemFromLoop.FieldName} not just {!FieldName}

    Recommended Pattern

    Here's the typical deduplication flow structure:

    HTML

     

    1. Loop through your collection

    2. Get Records (filter by unique identifier from current loop item)

    3. Decision: Does record exist?

    - If No → Add to "Records to Create" collection

    - If Yes → Skip (or add to "Records to Update" collection)

    4. After loop completes → Create Records (using "Records to Create" collection)

    Specific Things to Check

    Without seeing your exact configuration, here are the most likely culprits:

    In your Get Records element:

    • Are you filtering on the correct unique field (External ID, lookup, or combination)?
    • Is the filter comparing against the current loop item's field value?
    • Did you set "When no records are returned" to "Put null in the variable"?

    In your Decision element:

    • Are you checking if the Get Records variable Is Null (meaning no match found)?
    • Or checking if a collection variable's count equals 0?

    In your Assignment/Collection:

    • Are you adding the current loop item to a new collection only when the Decision confirms no duplicate exists?

    Best Practice Alternative

    Consider using upsert logic instead of pure deduplication:

    • Use an External ID field on your target object
    • Populate that External ID in your source collection
    • Use Create Records with "Use separate resources for each record" and let Salesforce handle the upsert
0/9000