web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Add, Update and Delete...
Power Automate
Unanswered

Add, Update and Delete an Item from a SharePoint List

(0) ShareShare
ReportReport
Posted on by 59

Hello,

 

I have a flow which is successfully adding or updating a SharePoint list from a Parse JSON Schema (the Parse is coming from a List Rows present in a table).

 

However, I need to include another condition, which is, if the item IS NOT in the Parse JSON output, then I want to delete it from the list.

 

This is my current flow:

muhepd1_0-1696976112845.png

The Get items has a filter query to only bring the Title values (in the list) that are equal to my main field in the Parse JSON (the item ID).

 

Can someone please help me adding the delete condition as well?

 

Thank you!

Categories:
I have the same question (0)
  • Michael E. Gernaey Profile Picture
    53,335 Super User 2025 Season 2 on at

    @muhepd1 

     

    Hi, I would like to clarify this.

     

    1. You have SharePoint list that has items.

    2. When you loop through the incoming data, you either Add or Update based on the Get Items

    3. But you also want to delete list item NOT in the json

    So for this one, I think you mean

     

    lets pretend the List has 4 rows

    Row 1 -ID A

    Row 2 -ID B

    Row 3 -ID C

    Row 4 -ID D

     

    Now in your Incoming data you have

    ID - A

    ID - B

    ID - C

    And ID - E

     

    A, B and C would be updates.

    E would be a create

    And then we want to Delete ID D because it wasn't in the data correct?


    If you like my answer, I would really appreciate if you please Mark it as Resolved, and give it a thumbs up, so it can help others

    Cheers

    Thank You
    Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
    https://gernaeysoftware.com
    LinkedIn: https://www.linkedin.com/in/michaelgernaey

  • muhepd1 Profile Picture
    59 on at

    You are correct, please keep in mind that the data (parse json) will come everyday with a new list of items.

     

    Thank you in advance for helping.

  • Michael E. Gernaey Profile Picture
    53,335 Super User 2025 Season 2 on at

    Hi @muhepd1 

     

    Here is what I would do.

     

    Assumption: I am making an assumption, that the key you are using to Filter in your Get items is a single column.

     

    So let's pretend that Key column is called ID and I am going to assume that the value is Unique in both your Parse JSON and your SharePoint list, so there are no duplicates.

     

    Step 1. Do a Select on your Parse JSON, pulling out your Key.

    -Click the Advanced Map Icon, because we do NOT want to enter a Key, just a value

    -Once you are in advanced mode click there, and in the expression type item() (yeap that)

     

    Step 2. Do a Get Items on your SharePoint list, but without any filters

    Step 3. Create a Select action on your Get Items (#2) and once again pull out the RowID (key)

    -Click the advanced mode again

    -Once you are in advanced mode click there, and in the expression type item() (yeap that)

     

    Step 4. initialize an Array Variable and leave it empty

     

    Step 5. Do an Apply to each on your Select from your Get items, we want to loop through our List

    -In the Apply to each ADD a Condition

    -In the Left side, you will add the Outputs of the Select from the ParseJSON

    -Change the comparer to "does not contain" (middle section)

    -On the right side just the Current Item or item() (expression) whichever you want

     

    Step 6. In the Yes side, which tells us the New ParseJSON List does NOT contain the ID from the SharePoint List

    -Add an Append to array variable 

    -put item() (the expression) or Current Item , which ever you prefer in the Value

     

    Step 7. Now you had your unique list of IDs from the SharePoint List, that are NOT in the New ParseJSON

    Loop through this list (Apply to each) and delete the rows from the SharPoint, based on that.

    Now if this isn the actual RowID from sharepoint you will have to do Get iTems, filter by the Id, then do a Delete

     

    And Done

     

    My Example

    I have 2 arrays of emails

    FLMike_0-1697036305717.png

    I do a select on both, using item() (not setting a key, just the value in advanced mode)

    FLMike_1-1697036331490.png

     

    I Create my NonMatching Array variable as empty

    FLMike_2-1697036377513.png

     

    Now I do my Apply to each on the Outputs of Email Address 1 aka (MyEmailAddresses array)

    And inside is my condition where I validate that the Outputs of my EmailAddress 2 Array does NOT contain the Current Item (aka item()) from the loop

    FLMike_3-1697036397663.png

    And if it doesn't I add item() to my NonMatchingArray

     

    And when the loop is done. I have my array of non matching email addresses.

    FLMike_4-1697036511519.png

     

     

     

    NOTE: To make this fastest, do the delete step BEFORE you do the INsert/Updates so that you arent adding more rows to iterate through for deletes.

     


    If you like my answer, I would really appreciate if you please Mark it as Resolved, and give it a thumbs up, so it can help others

    Cheers

    Thank You
    Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
    https://gernaeysoftware.com
    LinkedIn: https://www.linkedin.com/in/michaelgernaey

     

  • muhepd1 Profile Picture
    59 on at

    Hi, thank you for helping, but you lost me on Step 7. In particular this portion: "Now if this isn the actual RowID from sharepoint you will have to do Get iTems, filter by the Id, then do a Delete"

     

    The apply to each 3 is the one you are telling me to do, the apply to each 2 is the one I already had that is updating/creating.

     

    But, since I didn't fully understand the logic in your steps 1-6, I can't infer how to create step 7. Could you please walk me through?

     

    muhepd1_0-1697039156920.png

     

     

     

  • Verified answer
    Michael E. Gernaey Profile Picture
    53,335 Super User 2025 Season 2 on at

    Hi @muhepd1 

     

    I think you did good, it looks like you followed what I said, so we are close. I cannot see all of your details but let me explain it ,

     

    As I mentioned, I am assuming that in the ParseJSON there is some Field (I was pretending to call it RowID, I made that up, its a placeholder, for YOUR actual field), that allows you to Filter rows in the SharePoint List. 

     

    So that its only 1 column.

     

    What I am having you do

    1. Create a unique list of SharePoint items, just 1 column, but the column has to be the Unique column that is shared in the ParseJSON and in the SharePoint list, again I was pretending its called RowID,

     

    2. Create a unique list of ParseJSON items, just 1 column, but the column has to be the matching Unique column that you use in the Step #1,

     

    So you end up with 2 lists. that  look like this. Again I CANNO SEE YOUR DATA, so I am implying ad you need to put in your real stuff.

     

    Pretend output from Step 1 (SharePoint List)

    [ "1","2","3","4","5"]

     

    Pretend output from Step 2 (ParseJSON list)

    [ "2","3","4","5","6"] 

     

    When you look at this data, you would create #6, because its new in the ParseJSON output

    But #1 doesn't exist in the ParseJSON so you wanted to delete it.

     

    -So you loop through your List, which came from SharePoint List

     

    -Then you have a Condition, which checks to see if the SharePoint item, identified by the Loop, does NOT exist inside the ParseJSON list.

     

    If the answer is true, meaning it does not exist in the ParseJSON list, then we want to capture it in our temporary array variable.

     

    We could have just deleted it then, but I was trying to make it simple and clear.

     

    After you have looped through all of the SharePoint List items and validated whether they are or are NOT in the ParseJSON list, you have a complete Array of Non existent List items.

     

    But since I have NO IDEA what your column is called, i was calling it RoWID

     

    So what I was saying it, ok NOW you need to loop through the Non existent list, and call Get Items on the SharePoinst list, and do an eq filter on whatever row, is your unique row.

     

    So myrowvalue eq item() wherae item() is the current loop value of the Non existent list values.\

     

    So what is the name of the Column that is unique and can be used to filter/search rows both on the ParseJSON and on the SharePoint list?


    If you like my answer, I would really appreciate if you please Mark it as Resolved, and give it a thumbs up, so it can help others

    Cheers

    Thank You
    Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
    https://gernaeysoftware.com
    LinkedIn: https://www.linkedin.com/in/michaelgernaey

     

     

  • muhepd1 Profile Picture
    59 on at

    The column name is NCTID, but I got it working! Thank you very much!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard