cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tagustin2020
Impactful Individual
Impactful Individual

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
mdevaney
Super User
Super User

@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
mdevaney
Super User
Super User

@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

tagustin2020
Impactful Individual
Impactful Individual

This worked. Thank you Matthew!

@tagustin2020 
Excellent.  Glad I could help Teresa 🙂

tagustin2020
Impactful Individual
Impactful Individual

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!

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

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (1,030)