Forum Discussion

Inkey_Solutions's avatar
Inkey_Solutions
Copper Contributor
Jun 09, 2022

The attempted operation is prohibited because it exceeds the list view threshold

Hi,

 

We are fetching documents from specific folder using the below code. 

 

Microsoft.SharePoint.Client.List spList = clientContext.Web.Lists.GetByTitle("Testable");
    clientContext.Load(spList);
    clientContext.ExecuteQuery();

    CamlQuery camlQuery = new CamlQuery();
    camlQuery.ViewXml = @"<View Scope='RecursiveAll'>
                                                  <Query>
                                                      <Where>
                                                          <IsNotNull>
                                                              <FieldRef Name='Title'></FieldRef>
                                                          </IsNotNull>
                                                      </Where>
                                                      <OrderBy>
                                                       <FieldRef Name='Created' Ascending='true' />
                                                     </OrderBy>
                                                  </Query>
                                                </View>";

    Folder folder = clientContext.Web.GetFolderByServerRelativeUrl(relativeURL);
    clientContext.Load(folder);
    clientContext.ExecuteQuery();

    camlQuery.FolderServerRelativeUrl = folder.ServerRelativeUrl;
    ListItemCollection listItems = spList.GetItems(camlQuery);

    clientContext.Load(listItems, items => items.Include(
    item => item, item => item["Title"]));
    clientContext.ExecuteQuery();

 

The folder has 10-12 documents only but still, it is throwing the error  "The attempted operation is prohibited because it exceeds the list view threshold" when executing the last line.

No RepliesBe the first to reply

Resources