Frage

I'm having trouble paging through a list via SOAP.

I can retrieve a list, but it only ever returns the first 30 items. (which is the setting in the default view).

$methodName = 'GetListItems';
$listName = '{259134c5-fa87-441e-8c31-641b51193710}';
$camlQuery="";
$paging = urlencode('Paged=TRUE&p_ID=30');

$xmlAction = 
    '<GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
      <listName>' . $listName . '</listName>
      <query>' . $camlQuery . '</query>
      <queryOptions>
            <QueryOptions>
              <Paging ListItemCollectionPositionNext="' . $paging . '" />
            </QueryOptions>
          </queryOptions>
         </GetListItems>';

echo '<hr><h1>My Action is:</h1><pre>' . htmlentities($xmlAction) . '</pre>';

$client = new Nusoap_Client($wsdl,true);
$response = $client->call($methodName,$xmlAction);
echo '<hr><h1>Response:</h1><pre>' . htmlentities(print_r($response,true)) . '</pre>';

This returns a response like this, except there are 30 items.

Response:

Array
(
    [GetListItemsResult] => Array
        (
            [listitems] => Array
                (
                    [data] => Array
                        (
                            [row] => Array
                                (
                                    [0] => Array
                                        (
                                            [!ows_Region] => 7
                                            [!ows_District_x0020_ID] => 1902
                                            [!ows_District] => SOME ISD
                                            [!ows_Campus_x0020_ID] => 1902001
                                            [!ows_Campus] => MY H S
                                            [!ows_Grade_x0020_Range] => 09-12
                                            [!ows_FileRef] => 30;#sites/ti/Lists/Schools/30_.000
                                            [!ows_MetaInfo] => 30;#
                                        )

                                )

                            [!ItemCount] => 30
                            [!ListItemCollectionPositionNext] => Paged=TRUE&p_ID=30
                        )

                )

        )

)

The documentation says to get the next page, I need to provide the value returned in "ListItemCollectionPositionNext" and query again. That's what the above is doing, and it returns the same 30 records. This list has 26K items in it.

Its not a permission issue. I'm an admin for this list and can manipulate it via the sharepoint web gui.

What else am I missing folks?

War es hilfreich?

Lösung

I wasn't able to get paging to work but I was able to fake it using the ID column and rowLimit to filter the results of my list into pages.

Query for the first 'page' of 50.

<GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<listName>{259134c5-fa87-441e-8c31-641b51193710}</listName>
<query><Query>
            <Where>
            <And><Gt><FieldRef Name="ID"/><Value Type="Number">0</Value></Gt>
            <Leq><FieldRef Name="ID"/><Value Type="Number">50</Value></Leq>
            </And>
            </Where>
</query></Query>
<rowLimit><RowLimit>50</RowLimit></rowLimit>
</GetListItems>

and the second page of 50

<GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<listName>{259134c5-fa87-441e-8c31-641b51193710}</listName>
<query><Query>
            <Where>
            <And><Gt><FieldRef Name="ID"/><Value Type="Number">51</Value></Gt>
            <Leq><FieldRef Name="ID"/><Value Type="Number">100</Value></Leq>
            </And>
            </Where>
</query></Query>
<rowLimit><RowLimit>50</RowLimit></rowLimit>
</GetListItems>

FYI: These queries are sensitive to new line characters. Make sure to do this all on one line. I split it apart to make it easier to read.

This returns 50 rows.

 <rowLimit><RowLimit>50</RowLimit></rowLimit> 

This returns an empty set. (or it did in my environment)

 <rowLimit>
 <RowLimit>50</RowLimit>
 </rowLimit>

The settings of the default view don't factor in. RowLimit appears to override it. There is a default limit of 5000 items in a single result set.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top