Skip to main content
Community site session details

Community site session details

Session Id : hx14HuT+ltDW+U7ATQKSQj
Power Automate - Building Flows
Unanswered

Flow to check duplicates in Sharepoint List

Like (0) ShareShare
ReportReport
Posted on 19 Jun 2024 16:52:56 by 114

Hi 

I'm trying to set up an alert if there is a duplicate in a Sharepoint list once it has been modified.

 

This is what I've tried, but it's not working, it sends the email but doesn't tell me what has been duplicated, so I can't get the HTML table to work, I think. 

 

3. Initialize Variables

  • Click on "New step" and search for "Initialize variable".
    • Set the variable name to IDList, type to Array, and leave the value empty.
    • Add another variable for the HTML table.
      • Name: HTMLTable, Type: String, Value: "".

4. Get Items from the List

  • Click on "New step" and search for "Get items".
  • Configure the "Get items" action by selecting your SharePoint site address and list name (List A).

5. Append to Array Variable

  • Click on "New step" and search for "Apply to each".
  • In "Select an output from previous steps", select the value from the "Get items" action.
  • Inside the "Apply to each" control:
    • Add an "Append to array variable" action.
      • Variable: IDList, Value: ID from "Get items".
    • Add "Append to string variable" to build HTML table rows.
      • Variable: HTMLTable
      • Value:
        html
         
        <tr><td>@{items('Apply_to_each')['ID']}</td></tr>

6. Initialize HTML Table Header

  • Before the "Apply to each" loop, initialize the HTML table header.
    • Click on "New step" and search for "Set variable".
    • Variable: HTMLTable
    • Value:
      html
       
      <table border="1" style="border-collapse: collapse;"><tr><th>ID</th></tr>

7. Close HTML Table

  • After the "Apply to each" loop, close the HTML table.
    • Click on "New step" and search for "Append to string variable".
    • Variable: HTMLTable
    • Value:
      html
       
      </table>

8. Check for Duplicates

  • Click on "New step" and search for "Condition".
  • Condition: length(variables('IDList'))
    • Operator: greater
    • Value: 0

9. Send Email with HTML Table

  • Inside the "If yes" branch of the condition, send an email with the HTML table.
    • Click on "New step" and search for "Send an email (V2)".
    • Configure the email action:
      • Recipient: (your choice)
      • Subject: "Duplicate IDs Found"
      • Body:
        html
         
        <p>The following IDs are duplicated:</p> @{variables('HTMLTable')}

Complete Flow Outline

  1. Trigger:

    • When an item is created or modified.
  2. Initialize Variables:

    • IDList (Array)
    • HTMLTable (String, initialized to HTML table header)
  3. Get Items from List:

    • Retrieve items excluding the current item.
  4. Append to Array Variable:

    • Append IDs to IDList and build HTML table rows inside "Apply to each".
  5. Close HTML Table:

    • Append closing HTML tags to HTMLTable.
  6. Check for Duplicates:

    • Condition to check if IDList length is greater than 0.
  7. Send Email:

    • Send an email with the HTMLTable in the body if duplicates are found.
  • Anil_g Profile Picture
    668 Super User 2025 Season 1 on 21 Jun 2024 at 16:11:13
    Re: Flow to check duplicates in Sharepoint List

    @BenBennett321 

     

    the concat should go inside loop

     

    and to check open flow run page...and open the output of the final compose activity you would be able to see

     

    for detailed explanation check my reply here https://powerusers.microsoft.com/t5/Building-Flows/Compose-an-Html-table/m-p/2806423

     

    cheers

  • BenBennett321 Profile Picture
    114 on 21 Jun 2024 at 15:36:27
    Re: Flow to check duplicates in Sharepoint List

    Thanks for your reply:

     

    " Can you check the final html format created from the last append to string variable activity..from there we can see if html is proper"

     

    I'm not sure how to do this?

     

    and this "also here it should be like this with expression concat('<tr><td>',items('Apply_to_each')?['ID'],'</td></tr>')" 

     

    Where should the concat go? in the condition or somewhere else?

     

  • Anil_g Profile Picture
    668 Super User 2025 Season 1 on 19 Jun 2024 at 17:08:24
    Re: Flow to check duplicates in Sharepoint List

    @BenBennett321 

     

    1. First check flow run history and check if get items is retreiving the right items

    2. Can you check the final html format created from the last append to string variable activity..from there we can see if html is proper


    also here it should be like this with expression concat('<tr><td>',items('Apply_to_each')?['ID'],'</td></tr>')

     

    cheers

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1

Loading complete