Hide New and Upload button if the library exceeded 30k files

Julien Anid 216 Reputation points
2022-06-07T19:30:25.167+00:00

Hello everyone,

I have an SP library that allows the users to store files and create folders with the edit permission role.

When the library reaches the 30k number of items, I would like to hide the new & upload button from the ribbon and show a very simple alert for the user “You cannot create or upload any files/folders you have exceeded the limit, please create a new library”.

![209198-image.png]1

In that way I obliged the users to create a new library to avoid the limitations of SharePoint.

What will be the solution to achieve the above requirements?

Could you please provide an example?

Any help is highly appreciated.

Thank you.

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

Answer accepted by question author
  1. Tong Zhang_MSFT 9,256 Reputation points
    2022-06-08T07:09:55.177+00:00

    Hi @Julien Anid ,

    According to my research and testing, there is currently no way to automatically hide New and Upload button if the library exceeded 30k files and show a alert .As a workaround ,when the number of files reaches 30k, you can manually add JSON in the library to hide the New and Upload button. You can refer to the following steps:

    1.Go to the library, click Format current view (As shown in the screenshot)
    List item
    2.Click Advanced mode
    209296-image.png
    3.Copy the following JSON and paste in Format view:

    {  
      "commandBarProps" : {  
        "commands": [  
          {  
            "key": "new",  
            "hide": true  
          },  
          {  
            "key": "upload",  
            "hide": true  
          }  
        ]  
      }  
    }  
    

    209353-image.png
    4. Click Save , the New and Upload button will be hidden.
    209336-image.png


    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.


    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Paul de Jong 891 Reputation points
    2022-06-08T07:28:54.47+00:00

    Keep in mind that this only hides the New and Upload buttons in the browser. If documents are uploaded via other ways (e.g. OneDrive for Business client, ...) this will still be possible. If you want to prevent users from adding new content you will have to look at other means (e.g. change permissions).

    1 person 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.