Cannot bulk delete items from Sharepoint list

Pekka Pekkonen 586 Reputation points
2024-01-26T09:37:11.8666667+00:00

Hello I have a sharepoint list that has around 6000 items. I would like to delete items in bulk. I was actually able to delete first 200 items (edit: it turned out that is was probably only one item at a time so I was able to delete only 2 items). After that the delete button disappeared, see picture. How can I continue with the deletations, I wonder. User's image

Regards, Pekka

Microsoft 365 and Office | SharePoint | For business | Windows
0 comments No comments
{count} votes

Answer accepted by question author
  1. Xyza Xue_MSFT 30,241 Reputation points Microsoft External Staff
    2024-02-05T01:13:26.4933333+00:00

    Hello @Pekka Pekkonen ,

    I'm glad to hear you solve the problem, if you have any issue about SharePoint, you are welcome to raise a ticket in this forum.

    By the way, since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others." and according to the scenario introduced here: Answering your own questions on Microsoft Q&A, I would make a brief summary of this thread:

    Issue Symptom:

    Unable to batch delete items from Sharepoint list. After that, the delete button disappeared and appeared by using a different sort method. Users can delete one at a time.

    Current status:

    The issue has been solved. The solution was to use a computer that has this Sharepoint list added as a calendar on Outlook. There you could filter the list so that it contains less than 5000 items. Then it was possible to view them in a list form and do a bulk delete.

    You could click the "Accept Answer" button for this summary to close this thread, and this can make it easier for other community member's to see the useful information when reading this thread. Thanks for your understanding!


4 additional answers

Sort by: Most helpful
  1. Matteo Zamori 91 Reputation points
    2024-01-26T13:56:21.4033333+00:00

    It may happens time to time. If you refresh the web page or if you clear the browser cache and try again, it should normally work. You may consider using PowerShell instead if you have a lot data deletion to perform as you won't encounter this kind of behavior.

    0 comments No comments

  2. Pekka Pekkonen 586 Reputation points
    2024-01-29T08:47:14.2133333+00:00

    Thank you for the tips. Clearing cache did not help unfortunately but I actually managed to get delete button back by using different sorting. I believed already that I was able to delete at least 1000 items but according to List settings it was more like 10 items. User's image

    So the issue persists unfortunately. The provided script I can't use directly since newer list items are still in use.


  3. Pekka Pekkonen 586 Reputation points
    2024-02-03T09:25:25.25+00:00

    My colleque was able to solve this. The solution was to use a computer that has this Sharepoint list added as a calendar on Outlook. There you could filter the list so that it contains less than 5000 items. Then it was possible to view them in a list form and do a bulk delete.

    0 comments No comments

  4. Xyza Xue_MSFT 30,241 Reputation points Microsoft External Staff
    2024-01-29T02:59:51.6866667+00:00

    Hello @Pekka Pekkonen ,

    One possible reason for this is that SharePoint has a default limit of 5000 items that can be deleted at once.

    However, there are several ways to delete items in bulk from a SharePoint list:

    1.You can delete items in batches, making sure the number is under 5000 at a time.

    2.PowerShell: You can use PowerShell to delete all items from a SharePoint list.

    PowerShell to Delete All Items from Large Lists in SharePoint Online:

    Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
    Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
         
    #Config Parameters
    $SiteURL="https://crescent.sharepoint.com"
    $ListName="Projects"
    $BatchSize = 500
       
    #Setup Credentials to connect
    $Cred = Get-Credential
       
    Try {
        #Setup the context
        $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
        $Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)
       
        #Get the web and List
        $Web = $Ctx.Web
        $List=$web.Lists.GetByTitle($ListName)
        $Ctx.Load($List)
        $Ctx.ExecuteQuery()
        Write-host "Total Number of Items Found in the List:"$List.ItemCount
      
        #Define CAML Query to get list items in batches
        $Query = New-Object Microsoft.SharePoint.Client.CamlQuery
        $Query.ViewXml = "<View Scope='RecursiveAll'><RowLimit Paged='TRUE'>$BatchSize</RowLimit></View>"
      
        Do { 
            #Get items from the list in batches
            $ListItems = $List.GetItems($Query)
            $Ctx.Load($ListItems)
            $Ctx.ExecuteQuery()
              
            #Exit from Loop if No items found
            If($ListItems.count -eq 0) { Break; }
      
            Write-host Deleting $($ListItems.count) Items from the List...
      
            #Loop through each item and delete
            ForEach($Item in $ListItems)
            {
                #Delete SharePoint list items
                $List.GetItemById($Item.Id).DeleteObject()
            }
            $Ctx.ExecuteQuery()
      
        } While ($True)
      
        Write-host -f Green "All Items Deleted!"
    }
    Catch {
        write-host -f Red "Error Deleting List Items!" $_.Exception.Message
    }
    

    Remember to replace the variable $SiteURL, $ListName with your own.

    For more detail information:https://www.sharepointdiary.com/2015/10/delete-all-list-items-in-sharepoint-online-using-powershell.html#:~:text=SharePoint%20Online%3A%20Delete%20All%20List%20Items%20using%20PowerShell,item%20will%20be%20sent%20to%20the%20recycle%20bin

    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    2 people found this answer helpful.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.