2

In client environment we cannot let our hands on SharePoint list threshold. in such case rest api is not usable, there for i moved to the approach of content iterator and found that it also have a limitation each selected column has to be indexed and there is a limitation for no of columns that can be indexed in a list. any other alternative to retrieve 50,000+ records from Sharepoint list ?

3
  • 1
    you looking for client side solution or server side solution?
    – Taran Goel
    Commented Jul 8, 2015 at 6:23
  • As far as i can avoid the list threshold, server-side or client-side i do not mind. but as per to my research there is no solid approach from client side to retrieve 50k data.
    – 007ruwan
    Commented Jul 8, 2015 at 15:32
  • if my issue was not clear; i used content iterator as SharePoint rest api can not facilitate fetching more than 5000 records from list due to the list threshold limitation. and the alternative i found for this is the content iterator, which works extremely fine with some lists. but i have one list with 25 columns and all of them are required to be displayed. when using content iterator the view fields needs to be indexed and list has limitation of no of columns that can be indexed. So what i look for is how to overcome the list threshold issue while retrieving 50k records and all columns.
    – 007ruwan
    Commented Jul 8, 2015 at 15:38

2 Answers 2

7

How about using paging with the 'old' listdata.svc? It supports paging with the ODATA skip and top parameters like so:

http://sharepointsite/_vti_bin/listdata.svc/MyList?$skip=100000&$top=10000

Then you can pull e.g. 10,000 items at a time and iterate over the list contents. This is supported in SharePoint 2010, 2013 and Online.

2
  • the requirement is to display max 50,000 data in one grid. ( i know it sounds bit wired, but that's what client requested and as we are replicating an existing solution in a different environment its bit hard to convince them)
    – 007ruwan
    Commented Jul 8, 2015 at 15:35
  • 1
    I do not see an issue with this approach to show 50,000 plus items. You just cannot load all data at once, but in batches. Or, you can do paging in the grid and load data as the user clicks through the pager. You can also use third party grids that provide odata support that support skip/top... Commented Jul 8, 2015 at 16:23
0

It seems that you are using CAML query to retrieve and that query is exceeding the threshold limit.

Try this piece of code and try pulling from List itemposition:

ClientContext context = new ClientContext"Site URL");
 string username = @"username";
  string passw = @"password";
  SecureString passWord = new SecureString();
  foreach (char c in passw.ToCharArray()) passWord.AppendChar(c);
             {
     context.Credentials = new SharePointOnlineCredentials(username, passWord);

            }
  Web web = context.Web;
 try
         {
         int count = 0;
        List  Listname= context.Web.Lists.GetByTitle("name of the list");

         ListItemCollectionPosition itemPos = null;

          int intCount = 0;
          while (true)
               {
           CamlQuery cQuery = new CamlQuery();
             cQuery.ListItemCollectionPosition = itemPos;
             cQuery.ViewXml = "<View>"
               + " <RowLimit>1000</RowLimit>"
               + " </View>";

        Microsoft.SharePoint.Client.ListItemCollection items = Listname.GetItems(cQuery);
        context.Load(items);
        context.ExecuteQuery();
        itemPos = items.ListItemCollectionPosition;
        for (int iCntr = items.Count - 1; iCntr >= 0; iCntr--)

                    {

                      intCount++;
                      Microsoft.SharePoint.Client.ListItem listItem = items[iCntr];
                       listItem["Status"] = "Active";
             //Item is Retreivedinlistitem and now we are updating it to active
                      listItem.Update();
                     context.ExecuteQuery();

                    }

                    if (itemPos == null)

                    {

                        break;

                    }

                }

            }

            catch (Exception ex)

            {
               System.IO.StreamWriter file = new System.IO.StreamWriter("log Path", true);
                file.WriteLine(DateTime.Now + "    " + ex.Message);
                file.Close();



            }

Here all the items will be pulled in the while loop and you can play with them there itself.

For more details see this blog: http://expert-sharepoint.blogspot.in/2015/06/get-list-data-from-sharepoint-list-when.html

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.