cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Fuku-Shima
Helper I
Helper I

When I run the Remove function on multiple records, it fails to remove some of the records.

I am trying to delete multiple records in a SharePoint list with the following code.

Refresh('Table');
Remove(
  'Table',
  Filter('Table',ItemType = XX)
)

When this process is executed, it may fail to delete some records.
I have confirmed with the Monitor tool that the response of the deleteRows operation that is causing the error has the following contents.
"status": 400, "message": "Exception from HRESULT: 0x80131904 ...."

 

I've been using this app and SharePoint site for about a year, and I've noticed that the deletion process has been failing more frequently in the past few days compared to a year ago.
If there are more than 20 items to be deleted, the deletion process fails at least once in two times.
Incidentally, I don't feel that errors occur frequently in the insert and update processes.

 

I found a similar question, but I could not solve it with just this information.
> https://powerusers.microsoft.com/t5/General-Power-Automate/Exception-from-HRESULT-0x80131904-when-de...

 

I understand that this error is caused by a combination of factors, but I don't know where to start checking.
Please let me know the possible causes of the problem or give me some advice.
I would also appreciate it if you could ask me some questions to help me identify the cause.

 

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Neha
Frequent Visitor

Hi @Fuku-Shima , 

Did you try indexing the column on your Sharepoint list that you use in your filter? Indexing helps in delegation performance.

 

It seems RemoveIf can also be delegated if the criteria is delegable , please refer to this post https://powerusers.microsoft.com/t5/Building-Power-Apps/RemoveIF-function-and-PowerApps/td-p/918852 .

 

Also try using primary ID column in your filter and see if that makes a difference in the error you receive.

 

Thanks,

Neha

View solution in original post

9 REPLIES 9
v-bofeng-msft
Community Support
Community Support

Hi @Fuku-Shima :

Could you tell me:

Is the number of items in your data source greater than 500? If so, due to delegation, your remove operation may only be effective for the first 500 items.(You can set the threshold to a maximum of 2000)

In addition,maybe it is more stable to delete one by one:

Refresh('Table');
ForAll(
    Filter('Table',ItemType = XX) As A,
    Remove('Table',LookUp('Table',ID=A.ID));Notify("Deleting Item ID."&A.ID)
)

Best Regards,

Bof

RusselThomas
Community Champion
Community Champion

Hi @Fuku-Shima ,

I think you're right, indications seem to point to a source issue, not a PowerApps issue - is this SharePoint Online or on premises? 

Either way, I don't know what the underlying cause is, or whether this make a difference, and I like what @v-bofeng-msft suggested, but perhaps something else you can try is using RemoveIf() instead of a Filter?  Might result in the same Odata query and give you the same errors, but perhaps worth a try.

 

// Refresh('Table');  
//Try testing without this before the remove function, or place it after. 
RemoveIf(
  'Table',
  ItemType = XX
  )

 

I'm also curious as to the use of Refresh() before the remove - is it necessary?

I suspect it's an asynchronous call, in which case it might still be running when you run your remove - not sure if that could create a conflict, but try testing without it, or placing it after the Remove() function?

Hope you come right, let us know if anything works 🙂

Kind regards,

RT 

Hi @v-bofeng-msft 
Thanks for the reply.

 

I have well over 2000 items in my data source.
Therefore, I am careful that the result of the Filter I am running in Remove does not exceed the delegation limit.
Also, I was able to run Remove even with more than 10000 items, so I don't think the delegation issue is affecting this case.

 

The code you gave me gave me the error "This function cannot operate on the same data source used in ForAll", so I tried the following code. (The message may be a little different from your screen, as I am using it in a Japanese environment.)

 

Refresh('Table');
ForAll(
    Filter('Table',ItemType = XX).ID As A,
    Remove('Table',LookUp('Table',ID=A.ID));Notify("Deleting Item ID."&A.ID)
)

 

 I tried several times and was able to succeed in deleting about 200 records. Thank you.

 

However, in the case of iterative processing using ForAll, I am concerned about the following, since the getRows and deleteRow operations are repeated one record at a time.
(1) Limitation on the amount of API calls
In our environment, the plan is to call the API up to 2000 times a day. Therefore, we are worried about wasting the amount of API calls due to a large number of repetitive operations.
(2) Execution speed
When we tested it, we found out that it takes about 3 minutes to delete 200 items using ForAll.
I feel that the processing is slowed down by the getRows operation that occurs for each record.

 

I would be very happy if you could continue to give me advice.
Thank you in advance.

Hi @RusselThomas 
Thanks for the reply.

 

The data source I'm using is a SharePoint Online list.

The table to be removed has more than 2000 records, so I am using Remove('Table',Filter(,,)) instead of RemoveIf.

 

Since my application is designed to have more than 1000 users, I thought there was a high possibility of an error due to ETAG mismatch, so I wrote Refresh() before Remove().
I am referring to the following question about errors due to ETAG mismatch.
https://powerusers.microsoft.com/t5/Building-Power-Apps/Server-Response-ETAG-mismatch-clientRequestI...

 

Let me ask you one question.
I thought Refresh() was a function for synchronous calls, but is it an asynchronous function? If Remove() is executed without waiting for Refresh() to complete, then it needs to be replaced by another means. (For example, executing it with OnVisible on the screen.)
I couldn't understand it just from the Refresh function description page, so I hope you can tell me.

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-refresh

 

Please continue your advice.

Kind regards.

RusselThomas
Community Champion
Community Champion

hi @Fuku-Shima ,

To be honest, I'm not sure - it's maybe not the best test, but if I add a button to do something like this;

Refresh(Source);
UpdateContext({var: true})

and update a record in the backend, when I monitor the Network activity after pushing the button (using the browser devtools), it looks like the variable update happens immediately while the Refresh() is still getting data back, which looks like PowerApps is not waiting for the Refresh() to complete before moving on to the next line of code.

You can see this in a gallery when you update the data in SPO then hit refresh in the App, the variable updates long before the gallery updates.

It's not definitive, but I would expect the variable update to happen more or less at the same time as the Gallery update if it was synchronous...

Kind regards,

RT

hi @RusselThomas 

Thanks for the reply.

I have tried commenting out Refresh() and deleting multiple records with Remove(), but unfortunately I get the same error as before.

Also, since my app does not use a gallery with the value of the data source set in the Items property, the display refresh process that is performed as a result of Refresh() in that example does not seem to be executed. So I don't think there is any possibility of a data exchange conflict in Refresh.

I would be very happy to continue with your advice.
Thank you for your time.

Translated with www.DeepL.com/Translator (free version)

RusselThomas
Community Champion
Community Champion

Hi @Fuku-Shima ,

Bearing in mind, I think we're still looking at a source issue, not a PowerApps issue - so anything we try in PowerApps is only an attempt to work around what appears to be a source issue - meaning it may not be possible to work around it at all.  But we can keep trying until we've exhausted all avenues 🙂

Some additional questions:

  • Is this SharePoint Online, or SharePoint on premises?
  • If Online, is this a global commercial public cloud tenant? (i.e. not a specialised government or controlled tenant, i.e. Government, China, Germany or similar)  
  • Is there a row count threshold where you can reliably delete rows without an error every time?  (even if it's just two rows, it helps to know where the threshold is)
  • Ignoring delegation for now, do you get the same issue using RemoveIf()
  • Do you get the same issue running this on a different list in a different site?

Kind regards,

RT 

hi @RusselThomas 

Thanks for the reply.

  • Is this SharePoint Online, or SharePoint on premises?

The data source we are using is SharePoint Online.

  • If Online, is this a global commercial public cloud tenant? (i.e. not a specialised government or controlled tenant, i.e. Government, China, Germany or similar)  

The environment we are using is a global commercial public cloud tenant

 

  • Is there a row count threshold where you can reliably delete rows without an error every time? (even if it's just two rows, it helps to know where the threshold is)

I tried several times, but could not find the threshold.
I have never gotten an error when requesting a deletion of two rows.
However, I have had only one successful request to delete 10 rows.

 

  • Ignoring delegation for now, do you get the same issue using RemoveIf()

Using RemoveIf(), I was able to successfully delete almost 200 records.
However, since my app is designed to have a data source of more than 2000 records, RemoveIf() is not a solution.

 

  • Do you get the same issue running this on a different list in a different site?

It is not immediately possible to prepare a different list in a different site for verification, so I will try it later and report back.
Incidentally, I have a similar problem with a different list on a different subsite within the same site.

 

I would appreciate your continued advice.
Kind regards.

Neha
Frequent Visitor

Hi @Fuku-Shima , 

Did you try indexing the column on your Sharepoint list that you use in your filter? Indexing helps in delegation performance.

 

It seems RemoveIf can also be delegated if the criteria is delegable , please refer to this post https://powerusers.microsoft.com/t5/Building-Power-Apps/RemoveIF-function-and-PowerApps/td-p/918852 .

 

Also try using primary ID column in your filter and see if that makes a difference in the error you receive.

 

Thanks,

Neha

Helpful resources

Announcements

Celebrating the May Super User of the Month: Laurens Martens

  @LaurensM  is an exceptional contributor to the Power Platform Community. Super Users like Laurens inspire others through their example, encouragement, and active participation. We are excited to celebrated Laurens as our Super User of the Month for May 2024.   Consistent Engagement:  He consistently engages with the community by answering forum questions, sharing insights, and providing solutions. Laurens dedication helps other users find answers and overcome challenges.   Community Expertise: As a Super User, Laurens plays a crucial role in maintaining a knowledge sharing environment. Always ensuring a positive experience for everyone.   Leadership: He shares valuable insights on community growth, engagement, and future trends. Their contributions help shape the Power Platform Community.   Congratulations, Laurens Martens, for your outstanding work! Keep inspiring others and making a difference in the community!   Keep up the fantastic work!        

Check out the Copilot Studio Cookbook today!

We are excited to announce our new Copilot Cookbook Gallery in the Copilot Studio Community. We can't wait for you to share your expertise and your experience!    Join us for an amazing opportunity where you'll be one of the first to contribute to the Copilot Cookbook—your ultimate guide to mastering Microsoft Copilot. Whether you're seeking inspiration or grappling with a challenge while crafting apps, you probably already know that Copilot Cookbook is your reliable assistant, offering a wealth of tips and tricks at your fingertips--and we want you to add your expertise. What can you "cook" up?   Click this link to get started: https://aka.ms/CS_Copilot_Cookbook_Gallery   Don't miss out on this exclusive opportunity to be one of the first in the Community to share your app creation journey with Copilot. We'll be announcing a Cookbook Challenge very soon and want to make sure you one of the first "cooks" in the kitchen.   Don't miss your moment--start submitting in the Copilot Cookbook Gallery today!     Thank you,  Engagement Team

Announcing Power Apps Copilot Cookbook Gallery

We are excited to share that the all-new Copilot Cookbook Gallery for Power Apps is now available in the Power Apps Community, full of tips and tricks on how to best use Microsoft Copilot as you develop and create in Power Apps. The new Copilot Cookbook is your go-to resource when you need inspiration--or when you're stuck--and aren't sure how to best partner with Copilot while creating apps.   Whether you're looking for the best prompts or just want to know about responsible AI use, visit Copilot Cookbook for regular updates you can rely on--while also serving up some of your greatest tips and tricks for the Community. Check Out the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community.  We can't wait to see what you "cook" up!      

Tuesday Tip | How to Report Spam in Our Community

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   Today's Tip: How to Report Spam in Our Community We strive to maintain a professional and helpful community, and part of that effort involves keeping our platform free of spam. If you encounter a post that you believe is spam, please follow these steps to report it: Locate the Post: Find the post in question within the community.Kebab Menu: Click on the "Kebab" menu | 3 Dots, on the top right of the post.Report Inappropriate Content: Select "Report Inappropriate Content" from the menu.Submit Report: Fill out any necessary details on the form and submit your report.   Our community team will review the report and take appropriate action to ensure our community remains a valuable resource for everyone.   Thank you for helping us keep the community clean and useful!

Community Roundup: A Look Back at Our Last 10 Tuesday Tips

As we continue to grow and learn together, it's important to reflect on the valuable insights we've shared. For today's #TuesdayTip, we're excited to take a moment to look back at the last 10 tips we've shared in case you missed any or want to revisit them. Thanks for your incredible support for this series--we're so glad it was able to help so many of you navigate your community experience!   Getting Started in the Community An overview of everything you need to know about navigating the community on one page!  Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Community Ranks and YOU Have you ever wondered how your fellow community members ascend the ranks within our community? We explain everything about ranks and how to achieve points so you can climb up in the rankings! Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Powering Up Your Community Profile Your Community User Profile is how the Community knows you--so it's essential that it works the way you need it to! From changing your username to updating contact information, this Knowledge Base Article is your best resource for powering up your profile. Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Community Blogs--A Great Place to Start There's so much you'll discover in the Community Blogs, and we hope you'll check them out today!  Community Links: ○ Power Apps ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Unlocking Community Achievements and Earning Badges Across the Communities, you'll see badges on users profile that recognize and reward their engagement and contributions. Check out some details on Community badges--and find out more in the detailed link at the end of the article! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio    Blogging in the Community Interested in blogging? Everything you need to know on writing blogs in our four communities! Get started blogging across the Power Platform communities today! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Subscriptions & Notifications We don't want you to miss a thing in the community! Read all about how to subscribe to sections of our forums and how to setup your notifications! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Getting Started with Private Messages & Macros Do you want to enhance your communication in the Community and streamline your interactions? One of the best ways to do this is to ensure you are using Private Messaging--and the ever-handy macros that are available to you as a Community member! Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Community User Groups Learn everything about being part of, starting, or leading a User Group in the Power Platform Community. Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Update Your Community Profile Today! Keep your community profile up to date which is essential for staying connected and engaged with the community. Community Links: ○ Power Apps  ○ Power Automate  ○ Power Pages  ○ Copilot Studio   Thank you for being an integral part of our journey.   Here's to many more Tuesday Tips as we pave the way for a brighter, more connected future! As always, watch the News & Announcements for the next set of tips, coming soon!

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Top Solution Authors
Top Kudoed Authors
Users online (3,865)