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:
<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:
<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:
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:
<p>The following IDs are duplicated:</p> @{variables('HTMLTable')}
Complete Flow Outline
Trigger:
- When an item is created or modified.
Initialize Variables:
- IDList (Array)
- HTMLTable (String, initialized to HTML table header)
Get Items from List:
- Retrieve items excluding the current item.
Append to Array Variable:
- Append IDs to IDList and build HTML table rows inside "Apply to each".
Close HTML Table:
- Append closing HTML tags to HTMLTable.
Check for Duplicates:
- Condition to check if IDList length is greater than 0.
Send Email:
- Send an email with the HTMLTable in the body if duplicates are found.