cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Post Prodigy
Post Prodigy

How do I update a SharePoint List after deleting an item from a Collection?

@mdevaney I was wondering if you could help answer a quick Collection question for me. My PowerApps Gallery is based on a Collection from a SharePoint list (collected OnStart of the app). I'm able to add new items to the Collection and SharePoint simultaneously via my New Form and I'm able to edit items in the Collection and save them back to SharePoint with the Patch formula seen below. The issue I am having is with deletions. Row items are removed from the Collection just fine, but I can't figure out how to communicate the change back to SharePoint. The OnSelect formula for my trash icon is Remove(colPipeline,ThisItem). Is there a formula I need to enter into the OnSuccess property of the icon? Would it be some sort of ForAll Patch statement? If so, does the Patch formula below give you enough information to be able to advise me? I haven't used the ForAll function yet... Thanks in advance!

 

This is the Patch statement I'm using on the Save icon:

Patch(Pipeline,First(Filter(Pipeline,ID=ThisItem.ID)),
{Title:gal_txtCustomer.Text,
Category:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Value:gal_ddCategory.Selected.Value},
Chased:gal_calChased.SelectedDate,
Amount:Value(gal_txtBudget.Text)});
ClearCollect(colPipeline,Pipeline)

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User III
Super User III

@tagustin2020 

Hello there 🙂

 

I would suggest using this code to remove the record from both the Collection and SharePoint list in order.  I’ve used this code many times in my own apps so hopefully it will work for you.

 

Remove(your_datasource_name, LookUp(your_datasource_name, ID = ThisItem.ID));
Remove(colPipeline,ThisItem);

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

5 REPLIES 5
Highlighted
Super User III
Super User III

@tagustin2020 

Hello there 🙂

 

I would suggest using this code to remove the record from both the Collection and SharePoint list in order.  I’ve used this code many times in my own apps so hopefully it will work for you.

 

Remove(your_datasource_name, LookUp(your_datasource_name, ID = ThisItem.ID));
Remove(colPipeline,ThisItem);

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

Highlighted

This worked. Thank you Matthew!

Highlighted

@tagustin2020 
Excellent.  Glad I could help Teresa 🙂

Highlighted

Hello Matt,

 

I hope you are well. I have a follow-up question. It occurred to me that I should include a pop-up dialog box asking the user to confirm that they wish to delete the item. If they click the "Yes, delete" button it should be removed from the SharePoint list (Pipeline) and Collection (colPipeline). For some reason, the formula that worked for the trash can icon in the Gallery is not working on the "Yes, delete" button in the pop-up dialog box. I have a suspicion that I am doing something wrong with the variable, but I've been trying to get it going since Monday with no success so I thought I should ask you if you could help me out. Intellisense doesn't even give me the option of selecting "ThisItem". Since there are multiple formulas with the introduction of a pop-up dialog, I thought it would be easiest to attach screenshots in the pdf below. I have everything working except for the delete feature so I have highlighted anything that pertains to it in yellow. Would you mind taking a look and letting me know what I am missing? I have watched multiple videos on pop-up dialog boxes, while I was able to glean valuable formatting tips from each, none of them matched my particular deletion scenario unfortunately. Thank you in advance!

Highlighted

@mdevaneyHi Matt, tagging you just in case that is necessary in order for you to see my latest inquiry below...thanks.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (8,091)