cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tomgardzinski
Helper IV
Helper IV

Creating an Item in a Sharepoint List that is based of another SP List

I'm trying to craft a Flow that really should be simple, but I'm struggling.

Basically I want SP1 to update SP2 only if a particular item (Course Title) is not in the SP2.

Currently, I'm performing this with the below:

Image1.JPG

Image2.JPG

Where my SPL1 (Create) is:

Image3.JPG

And my SP2 is:

Image4.JPG

The problem I am witnessing is this:

If I create an item in SP1 where course title is "Introduction to Marketing" as an example, the Flow goes to check if "Introduction to Marketing" is listed in SP2 as it should. As intended, it sees that it is not there and populates SP2 with "Introduction to Marketing". The first run through in the Apply to Each creates "Introduction to Marketing" and places it beneath the last entry (Media Relations as shown above). However, the Flow then continues in the Apply to Each loop and checks again to see if "Introduction to Marketing" is in the list. I assume it is now comparing with "Cost Accounting" which is the second entry in the list. The Flow realizes that "Introduction to Marketing" does not equal "Cost Accounting" and therefor creates another "Introduction to Marketing" beneath the last and newly created "Introduction to Marketing" from the first run through.

 

Basically I want the flow to search the entire list to see if "Introduction to Marketing" is in the list, if it is not add 1 entry of "Introduction to Marketing". Or, to explain it differently, I want my Flow to stop when a new item is created in SP2, and not run through the entire Apply to Each cycle.

With the current Flow above, I run it, and end up with 6 entries of "Introduction to Marketing". Because, as I suspect, it compares "Introduction to Marketing" to each line item (6 line items), and realizes that none of them are Introduction to Marketing, and therefor creates 6 entries in SP2.

 

Can someone tell me how to ensure only 1 entry occurs in the SP2 if it is not in the list?

 

Any help would be greatly appreciated.

 

Thanks,

Tom

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @tomgardzinski,

 

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

  • Add “When an item is created” trigger, specify Site Address and set List Name to TEST Booklist.
  • Add “Get items” action, specify Site Address and set List Name to TEST Course Leads.
  • Add Variables-> “Initialize variable” action, Name set to CourseTitleArray, Type set to Array and Value remain empty.
  • Add a “Apply to each” action, Input parameter set to output of “Get items” action. Within “Apply to each” action, add “Append to array variable” action, Name choose CourseTitleArray, Value set to Course dynamic content of “Get items” action.
  • Under “Apply to each” action, add a Condition, left input box set to variable CourseTitleArray, right input box set to Course Title dynamic content of the trigger, within middle drop down, choose contains.
  • Within “If/no” branch of Condition, add a “Create item” action.

Image reference:9.JPG

 

10.JPG

The flow works successfully as below:11.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

2 REPLIES 2
v-xida-msft
Community Support
Community Support

Hi @tomgardzinski,

 

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

  • Add “When an item is created” trigger, specify Site Address and set List Name to TEST Booklist.
  • Add “Get items” action, specify Site Address and set List Name to TEST Course Leads.
  • Add Variables-> “Initialize variable” action, Name set to CourseTitleArray, Type set to Array and Value remain empty.
  • Add a “Apply to each” action, Input parameter set to output of “Get items” action. Within “Apply to each” action, add “Append to array variable” action, Name choose CourseTitleArray, Value set to Course dynamic content of “Get items” action.
  • Under “Apply to each” action, add a Condition, left input box set to variable CourseTitleArray, right input box set to Course Title dynamic content of the trigger, within middle drop down, choose contains.
  • Within “If/no” branch of Condition, add a “Create item” action.

Image reference:9.JPG

 

10.JPG

The flow works successfully as below:11.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

Hi Kris,

It worked! At first it wasn't working because I had the filter query in the "Get Item" set to a value, I cleared that. Then I also had to move the condition statement outside of the "Apply to Each" statement.

Thank you so much for your help. I can see how putting my data into an array will help me going forward.

 

Tom

 

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.

Top Solution Authors
Users online (3,107)