Hello everyone,
I spent couple of days trying to get Power Automate to remove duplicates from a Sharepoint List to automate emails.
My list is organised as followed: Title, Status, Full Name, Email Address, ID
The type of duplicate I will have will be as such:
Title, Status, Full Name, Email Address, ID
001, To send, Name 1, Email 1, 1
001, To send, Name 1, Email 1, 2
My goal is to email all the people in my list only once and ignore the duplicate which will be deleted later in the flow.
My current flow aims to get all items and store all their information in a variable "All contacts" (array).
Then, I have a second variable "Unique contacts" (array) that is empty and I want to use in a condition action.
The condition action checks if the Title in "All contact" is NOT in "Unique contact". If true, it adds all the information to Unique contacts, and go to next.
(The compose actions are here to see the output and troubleshoot. Power Automate sometimes do not show the input output without a refresh which is time consuming...)
In all the array variables the information is formatted as such:
{
"Tile": "@{item()?['Title']}",
"Email": "@{item()?['Email']}",
"ID": "@{item()?['ID']}",
}
I am not used to work with array and struggle to get PA to compare the Title of the objects in both arrays. I tried:
variables('Unique contacts') DOES NOT CONTAIN items('Compare arrays')?['Title']
But is give TRUE to all entries (incl the duplicates). I figured it is because I do not point to the Unique contacts Title and the current items Title in the loop. However code below gives me the error:
variables('Unique contacts')?['Title'] DOES NOT CONTAIN items('Compare arrays')?['Title']
Action 'Compare arrays' failed: Unable to process template language expressions for action 'Compare arrays' at line '0' and column '0': 'The template language expression 'variables('Unique contacts')?['Title']' cannot be evaluated because property 'Title' cannot be selected. Array elements can only be selected using an integer index. Please see https://aka.ms/logicexpressions for usage details.'.
I thought it was because "Unique contacts" is empty and does not have a Title to select on the first iteration of the loop, so I set the initial value:
[
{
"UKSCB Ref": "Empty"
}
]
But this gave me the same error.
I have tried everything I think could work and I am now clueless about what the issues is (comparison statement? empty array? something else?).
May I ask for your advice?
I greatly appreciate any contributions to this problem.