Sharepoint Web Service GetListItems not returning all rows
Asked Answered
I

7

5

I am using the GetListItems web service and it is only returning about 50% of the results stored. Is there a limit to how much data can be returned? Is there anyway round this?

Import answered 21/8, 2009 at 22:27 Comment(1)
Could you share the mechanism (code, if possible) that you're using to retrieve the data. Also, how many items are you getting back, and how many total are in the list?Sandler
G
5

The method retrieves only the number of rows in the default view of the list. To solve this problem, you can simply increase the row count in your default view, or better yet, use CAML queries. Here's an article on how to use CAML with web services: http://dotnet.org.za/zlatan/archive/2007/08/01/collaborative-application-markup-language-caml-and-webservices-in-sharepoint-2007.aspx

Gabie answered 22/8, 2009 at 15:9 Comment(1)
That link is broken. Bummer.Lawannalawbreaker
D
4

From my experience you have to options: 1. Change the view you use when calling the getlistitems method to the correct view which returns all rows 2. Check and see if you placed a rowlimit in your getlistitems method. If you want to return everything in the current view that you have you can use "0" see example below: XmlNode doc = doclist.GetListItems("My List", "My View", query, viewFields, "0", queryOptions, null);

You can also try and go to your SharePoint site, go to the list you are pulling from then select settings and modify the default view/create your own view and expand the Totals group. Under the Totals group, look for a unique identifier for your list (eg. ID) then in the dropdown beside it select COUNT then save your view. Once the list reloads compare the total number which will now be shown in this view with the number of items returned by your query. Let me know if they are still not the same. :)

Dressing answered 24/10, 2011 at 4:31 Comment(0)
H
2

Refer this article you number of rows returned is based on the View you have used, Change the rowlimit in the View.

Herrenvolk answered 22/8, 2009 at 2:29 Comment(0)
H
1

Try this, SharePoint List Web Service GetListItems

Harmonic answered 30/12, 2009 at 12:2 Comment(0)
S
1

GetListItems() limits results based on the Row Limit of the View you are using as the second parameter in the method call. If you need all rows to be returned:

  1. Go to your SharePoint site using your favorite (or least favorite) Web Browser
  2. Navigate to your List
  3. Select the View which corresponds to the GUID you are using as the second parameter of your GetListItems() method call (see example below)
  4. Select (from the View drop-down menu) "Modify this View"
  5. Scroll all the way to the bottom and expand "Item Limit"
  6. Set a high number (I used 9000) as the "Number of items to display" and select "Limit the total number of items returned to the specified amount."
  7. Click OK.

    Service.GetListItems(ListGuid, ViewGuid, query, viewFields, RowLimit, queryOptions, null);

If the RowLimit method parameter is less than the View Row Limit you had set up in SharePoint, then the results are limited to the parameter value.

Sofar answered 20/4, 2012 at 20:36 Comment(0)
C
1

Just for reference to other people who get here from google.

I need to extract data from a legacy system and happen to have this same exact problem. The difference is I didn't have control over the sharepoint list so I can't change the default view.

var items = listSvc.GetListItems(listname, null, null, null, null, null);

var pager = items.ChildNodes[1].Attributes["ListItemCollectionPositionNext"] != null ? items.ChildNodes[1].Attributes["ListItemCollectionPositionNext"].Value : string.Empty;
var pagerXml = new XmlDocument();
pagerXml.InnerXml = "<QueryOptions><Paging ListItemCollectionPositionNext=\"\" /></QueryOptions>";
var pagerNode = pagerXml.GetElementsByTagName("QueryOptions")[0];

while (!string.IsNullOrEmpty(pager))
{
    pagerNode.ChildNodes[0].Attributes[0].Value = pager;
    var temp = listSvc.GetListItems(listname, null, null, null, null, pagerNode);
    foreach (XmlNode c in temp.ChildNodes[1].ChildNodes)
    {
        var c2 = items.OwnerDocument.ImportNode(c, true);
        items.ChildNodes[1].AppendChild(c2);
    }

    pager = temp.ChildNodes[1].Attributes["ListItemCollectionPositionNext"] != null ? temp.ChildNodes[1].Attributes["ListItemCollectionPositionNext"].Value : string.Empty;
}

This is one time use code, so I leave it to the reader to tidy it up:D

but the gist is, if you can't get it in one call, just get it in batches using the view page size as the batch size. The last argument of GetListItems() accepts an XmlNode parameter and you can pass something like:

<QueryOptions><Paging ListItemCollectionPositionNext="{paging-option}" /></QueryOptions>

where {paging-option} is the value of the attribute (same name) of rs:data

Cathryncathy answered 27/9, 2013 at 11:37 Comment(0)
T
1

Set rowLimit to 0

var rowLimit = "0";
var result = client.GetListItems("ListName", null, query, viewFields, rowLimit, queryOptions, null);

Beware of timeouts. If you have lot of items in your SharePoint list then you might hit http timeout. Timeouts can be changed in IIS and web.config of your SharePoint site

Tonus answered 26/6, 2015 at 0:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.