cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
shibathedog
Helper I
Helper I

Check if record exists in Sharepoint and if not - create item

Hi all, I am very new to Power Automate so I would ask for some help. I managed to do the following:
I get data from SAP, parse JSON from it, filter the array from parsed json, set variable for every entry and make a new array out of it (append to array variable).
I get data from Sharepoint, compose the column I need, set variable from items in it, and append it to array variable.

 

In the last step I want to make a condition to check if the elements from SAP new array exist in the Sharepoint array, and if not, I would like to add them to the Sharepoint table (create item).


I tried numerous things but I either end up with 1 new entry, with duplicated entries, with multiplied entries (for array x array items) or with a blank entry. Can somebody please advise? Thank you very much for the help!!

shibathedog_0-1630511968589.png

 

 

shibathedog_1-1630512002153.png

 

shibathedog_2-1630512025200.png

 

In the screenshoted example I have: 2 entries in the Sharepoint, 7 entries in the SAP array (of which 5 should be written to sharepoint) but I end up with 7 times one of the entries (so the same entry entered 7 times and nothing except it).

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
shibathedog
Helper I
Helper I

Solved it! I should've passed item() to reference items in the list, and not the name of the variable which went into the array. The same for writing to sharepoint.

View solution in original post

5 REPLIES 5
shibathedog
Helper I
Helper I

Solved it! I should've passed item() to reference items in the list, and not the name of the variable which went into the array. The same for writing to sharepoint.

Hi Shibathedog,


Do you mind sharing your end results? I'm stuck with the same problem, but having no clue what you mean.. 
Thanks in advance! (:

Hi @MashaOvchar ,

 

I hope this will help you:

ans1pa.jpg

 

If not, please share your problem and I might be able to help out!

Hi @shibathedog ,

 

thanks for the fast reply! But it seems I'm still having trouble.. My initial flow was, when a .JSON is created in a Sharepoint folder, it needs to be parsed, then an item needs to be created in a Sharepoint list.
But at the end I want to check if an item (eg. filtered on OrderNumber) already exist in the list, if so it needs to be updated, otherwise a new item should be created. Have tried a couple of times.. most of the time the flow gets in a loop.. 

Initial flow:

MashaOvchar_0-1653641965021.png

MashaOvchar_1-1653642271727.png


What do you think? Any ideas?

shibathedog
Helper I
Helper I

I think the Apply to each x3 is too much to handle, well depending on the number of items you have. Can you try to do a condition with a create item if it doesn't exist and an update item if it exists?

Helpful resources

Announcements
 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Users online (3,211)