Skip to main content

"You cannot select more than 100 items at once" in SharePoint 2010

·3 mins

Looking for some solution for batch items update I’ve run into the following problem: when I clicked a checkbox in top right corner of the list (actually a document library) “All Items” view, the browser displayed an error: You cannot select more than 100 items at once.

Items selection limit - error message
Items selection limit - error message

The problem was discussed on the TechNet forum (Selecting more than 100 files in Document Library) and the limit of maximum 100 items per one batch update (like check-in, delete etc.) is described on MSDN:

Limit: Bulk operations
Maximum value: 100 items per bulk operation
Limit type: Boundary
Notes: The user interface allows a maximum of 100 items to be selected for bulk operations.

What is interesting and what was not mentioned in TechNet topic, the limit is controlled on client side by a script, what I will show. What happens when you click on select-all-items check box? This is a pseudo-callstack of JS calls:

<input type="checkbox"   
       title="Select or deselect all items"   
       onclick="ToggleAllItems(event,this,21)"   
       onfocus="EnsureSelectionHandlerOnFocus(event,this,21)" />  
onClick (the view HTML) ->  
ToggleAllItems(evt, cbx, ctxNum) (init.js) ->  
CoreInvoke(fn) (init.js) ->  
_ToggleAllItems(evt, cbx, ctxNum) (core.js) ->  
ToggleAllItems2(cbx, ctxNum, f) (core.js) ->  

In the last function - ToggleAllItems2 - you will find the following pieces of code:

var totalItems=CountTotalItems(ctxCur);  
// ...  
if (totalItems > g_MaximumSelectedItemsAllowed)  
{  
    cbx.checked=false;  
    alert(L_BulkSelection_TooManyItems);  
    return;  
}  

Variables g_MaximumSelectedItemsAllowed and L_BulkSelection_TooManyItems are defined in the same file (core.js):

var g_MaximumSelectedItemsAllowed=100;  
var L_BulkSelection_TooManyItems="You cannot select more than 100 items at once.";  

You will find a similar code checking if the limits are also preserved when user checks items one by one.
The second interesting thing is that the number of items is checked only on client side, so if you change g_MaximumSelectedItemsAllowed value to, let say 200, you will be able to make a batch update for more items than the official limit allows.
I’ve managed to change this by IE developers toolbar for 200 items:

Maximum selected items limit overwrite
Maximum selected items limit overwrite

Of course if you want to change this permanently (probably with changing the message string L_BulkSelection_TooManyItems also to not confuse users) you still will have to develop some more persistent solution - i.e. deploy your custom script into Layouts folder, link it on selected pages and so on. The code would look like this (I assume you have jQuery included):

$(document).ready(function() {  
    g_MaximumSelectedItemsAllowed = 200;  
    L_BulkSelection_TooManyItems = "You cannot select more than ' + g_MaximumSelectedItemsAllowed + ' items at once.";  
});  

There is one other issue I should mention. Limit of 100 items has been set for some reason - probably the performance. I’ve managed to update value of a column for 200 items with BatchEdit from codeplex but checking-in the same number of items failed (I’ve got some strange JS error). Still I was able to check-in 110 items which was above the standard limit.

Happy SharePointing!

A notice for archeologists...🏺 This post was originaly published on my previous blog and moved here. Some links and resources might not be up to date.