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."

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
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

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