cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper V
Helper V

How can I remove all items in a collection from a SharePoint list?

I have a collection of items that I want to remove from SharePoint. I want to remove all of the items when a button is clicked if they are in said collection. The items in the collection are added directly from a gallery that contains the SharePoint items, so the data is exactly the same.

 

I assume I need to use Remove, RemoveIf, or a combo of one of these with ForAll, but I cannot figure it out.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: How can I remove all items in a collection from a SharePoint list?

@pwrappr01 

You have used an equals operator (=).  Recheck the formula I posted, it uses an in operator.

RemoveIf('Call Metrics Reporting',ID in colItemstoDelete.ID)

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

10 REPLIES 10
Highlighted
Super User
Super User

Re: How can I remove all items in a collection from a SharePoint list?

@pwrappr01 

You can use the RemoveIf function.

Without knowing specifics of you data, a generic example would be this:

RemoveIf(yourSPList, ID in yourCollection.ID)

 

I hope this is helpful for you. 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Highlighted
Helper V
Helper V

Re: How can I remove all items in a collection from a SharePoint list?

@RandyHayes  , thanks for responding. I'm getting the following error:

Invalid argument type (table). Expecting Boolean value instead.

I've configured this as follows:

RemoveIf('Call Metrics Reporting',ID=colItemstoDelete.ID)

The collection can contain 1 or more items from an SP list, but they are literally captured from a gallery and stored in the collection.

Highlighted
Super User
Super User

Re: How can I remove all items in a collection from a SharePoint list?

@pwrappr01 

You have used an equals operator (=).  Recheck the formula I posted, it uses an in operator.

RemoveIf('Call Metrics Reporting',ID in colItemstoDelete.ID)

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

Highlighted
Helper V
Helper V

Re: How can I remove all items in a collection from a SharePoint list?

Doh! That was the problem-child. Thank you much. You are a gentleman and a scholar.

Highlighted
Super User
Super User

Re: How can I remove all items in a collection from a SharePoint list?

@pwrappr01 

Any time!

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Highlighted
Community Champion
Community Champion

Re: How can I remove all items in a collection from a SharePoint list?

@pwrappr01 @RandyHayes 

For my own learning, I'd be interested to know if this use of 'in' throws a delegation warning or silent delegation (my term, where you don't get a warning but the formula only returns up to 2000 items)?

 

Seems to be a grey area in my knowledge I'd like to get more info about.

 

Cheers

Highlighted
Super User
Super User

Re: How can I remove all items in a collection from a SharePoint list?

@Eelman 

No, the in operator is not a delegable operator.  It will throw a delegation warning.

The second term you refer to as silent delegation already has a name...it's called Data Row Limit.  It is controlled in the advanced settings.  If your Remove operation includes the removal of the amount of records you have in the limit, then it will not be complete. 

 

If delegation on large data sources is a concern, then other provisions for removing are needed. Such as a slower, but usable, ForAll with an embedded RemoveIf.  Not very efficient.  And even that can be subject to delegation issues as well as record limit issues (depending on the amount).

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Highlighted
Community Champion
Community Champion

Re: How can I remove all items in a collection from a SharePoint list?

@RandyHayes 

Thanks mate, always great to get you insights. I was thinking that you knew something I didn't because you were pointing the 'in' at a collection rather than a datasource and somehow this was different. Alas, not to be 🙂

 

I will try to use 'Data Row Limit' more but I think my brain will always associate this process with the word 'silent' so that I remember to check my functions, lol.

 

Great to see you back answering Qs on the forums as well mate. I enjoy your input and do my best to read and learn from it.

 

Thanks again.

Highlighted
Helper V
Helper V

Re: How can I remove all items in a collection from a SharePoint list?

@RandyHayes, is there a way to configure this solution to avoid delegation issues as that is indeed a concern with the project I posted about? For example, would sorting the data prior to applying the RemoveIF at least ensure recent items are being deleted?

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

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,436)