cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Pipcraz
New Member

Prevent duplicate if already exists in List 2

Hi all and thank you in advance!

 

I have a MS Flow where upon modifying an item from List 1 and the status equals to "Complete" create a new item in List 2. Now this works good but IF I modify something in Complete status from List 1, it creates a duplicate item in List 2. If a modify something in Complete status multiple times, it creates multiple items in List 2 irrespective if it already exists in List 2.

 

Is there any ways I can prevent an item from List 1 that already exists in List 2 from creating duplicate items in List 2? Is there any wayt to place a check/verification before creating an item in List 2?

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @Pipcraz,

 

Could you please share a bit more about your two SharePoint lists (List 1 and List 2)?

Does the List 1 and List 2 have same data structure?

 

I have created two SharePoint lists on my side and the data structure as below:

List 1:18.JPG

Note: TaskName column is a Single line of text type column, Due Date column is a Date type column and the Status column is a Choice type column (Available values: In Progress and Complete).

 

List 2:19.JPGNote: ItemIDFromList1 column is a Number type column, which is used to store the item ID from the List 1. TaskName column is a Single line of text type column and Due Date column is a Date type column. 

 

I have made a test on my side and please take a try with the following workaround:

  • Add a "When an item is created or modified" trigger, specify Site Address and List Name set to List 1.
  • Add a Condition, left input box set to Status Value dynamic content of the trigger, right input box set to Complete. Within middle drop down, choose is equal to.
  • Within "If/yes" branch of Condition, add a "Get items" action, specify Site Address, List Name set to List 2. Add a "Filter array" action, From set to output of "Get items" action, within Condition box, left input box set to ItemIDFromList1 dynamic content of "Get items" action, right input box set to ID dynamic content of the trigger. Within middle drop down, choose is equal to.

         Add a "Condition 2" action, click "Edit in advanced mode", type the following formula:

@empty(body('Filter_array'))

     Within "If/yes" branch of Condition 2, add a "Create item" action, Title field, ItemIDFromList1 field, TaskName field and Due Date field are set to corresponding dynamic contents of the trigger.

     Within "If/no" branch of Condition 2, add a "Apply to each" action, input parameter set to output of "Filter array" action. Within "Apply to each" action, add a "Update item" action, Id field set to following formula:

item()?['ID']

Title field set to following formula:

item()?['Title']

TaskName field and Due Date field set to corresponding dynamic contents of the trigger.

 

Image reference:20.JPG

 

21.JPG

The flow works successfully as below:22.JPG

 

 

 

Best regards,

Kris

 

 

 

 

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-xida-msft
Community Support
Community Support

Hi @Pipcraz,

 

Could you please share a bit more about your two SharePoint lists (List 1 and List 2)?

Does the List 1 and List 2 have same data structure?

 

I have created two SharePoint lists on my side and the data structure as below:

List 1:18.JPG

Note: TaskName column is a Single line of text type column, Due Date column is a Date type column and the Status column is a Choice type column (Available values: In Progress and Complete).

 

List 2:19.JPGNote: ItemIDFromList1 column is a Number type column, which is used to store the item ID from the List 1. TaskName column is a Single line of text type column and Due Date column is a Date type column. 

 

I have made a test on my side and please take a try with the following workaround:

  • Add a "When an item is created or modified" trigger, specify Site Address and List Name set to List 1.
  • Add a Condition, left input box set to Status Value dynamic content of the trigger, right input box set to Complete. Within middle drop down, choose is equal to.
  • Within "If/yes" branch of Condition, add a "Get items" action, specify Site Address, List Name set to List 2. Add a "Filter array" action, From set to output of "Get items" action, within Condition box, left input box set to ItemIDFromList1 dynamic content of "Get items" action, right input box set to ID dynamic content of the trigger. Within middle drop down, choose is equal to.

         Add a "Condition 2" action, click "Edit in advanced mode", type the following formula:

@empty(body('Filter_array'))

     Within "If/yes" branch of Condition 2, add a "Create item" action, Title field, ItemIDFromList1 field, TaskName field and Due Date field are set to corresponding dynamic contents of the trigger.

     Within "If/no" branch of Condition 2, add a "Apply to each" action, input parameter set to output of "Filter array" action. Within "Apply to each" action, add a "Update item" action, Id field set to following formula:

item()?['ID']

Title field set to following formula:

item()?['Title']

TaskName field and Due Date field set to corresponding dynamic contents of the trigger.

 

Image reference:20.JPG

 

21.JPG

The flow works successfully as below:22.JPG

 

 

 

Best regards,

Kris

 

 

 

 

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Anonymous
Not applicable

Great reply but I have another similar scenario I hope you can help with.  I have the same scenario as above with two lists that should have new items triggered when the status field changes. List 1 is a Training list that has a document ID for a document that requires training.  The Training list(List 1) has a person field that you can enter multiple name of users that need trained when the Document is changed and approved.  In the Training Certificates list(List 2) I am creating an Item for each of the users that need trained from the Training List when a new item is created or modified.   I cannot use the filter array to lookup the ID in the Training Certificates list(list 2) becuase there is already many entries for the document ID but they are associated with different users that need trained.

 

example:

Training List has document ID JC0101 and has John Smith and Mary Jones as trainees.  When the form is created I create 2 new items in List 2.  They both have the ID of JC0101 but I am adding there name to the ID.  JC0101-John Smith

 

If I open the Training List(List 1) after I have already created the certificates in List 2, and I add another person in the Trainees field, It creates all of the certificates over again and adds the new trainee.  So now I have 5 items in the certificates list(list 2) instead of 3.

 

How can I use the Filter array to compare the lists?  Is there another way of accomplishing this?

 

The final result should be that I can add users to the person field in list 1 and the flow should only create new items in list 2 if there currently is not an item for that person.  

 

 

Note: if anyone trying to do this step:

 

Add a "Condition 2" action, click "Edit in advanced mode", type the following formula:

 

does not see 'Edit in advanced mode' then you can do something like this (in the 3 boxes):

 

empty(body('Filter_array')) - is equal to - true

 

Anonymous
Not applicable

i followed your steps but nothing created on the list 2

 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (1,823)