Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieving a large list of items from sharepoint - new method confusion #330

Open
stuartpaulin opened this issue May 22, 2023 · 1 comment
Labels

Comments

@stuartpaulin
Copy link

Referring to the 3.0.1 change that meant the old getItems() now only returns 100 items and the replacement is a getAll().

I note from the notes the suggested method is:
$ctx = (new ClientContext($siteUrl))->withCredentials($credentials);
$list = $ctx->getWeb()->getLists()->getByTitle("--large list title--");

$allItems = $list->getItems()->getAll(5000, function ($returnType){
print("{$returnType->getPageInfo()} items loaded...\n");
})->executeQuery();

In the large items example file similar but different code is suggested.

I replaced my function:

private function getSharePointListByTitle($titleURL)
{
    $list = $this->ctx->getWeb()->getLists()->getByTitle($titleURL);

    $items = $list->getItems();
    $this->ctx->load($items);
    $this->ctx->executeQuery();

    return $items;
}

with

private function getSharePointListByTitle($titleURL)
{
    $list = $this->ctx->getWeb()->getLists()->getByTitle($titleURL);

    $allItems = $list->getItems()->getAll(5000, function ($returnType){
        print("{$returnType->getPageInfo()} items loaded...\n");
    })->executeQuery();

    return $allItems;
}

But no luck. I can see that 567 items are returned in the sub function and printed to screen, but I can't see how I can extract them to actually use them. Would you expand on the example to explain it please. I'm guesing it is something like another $allItems->getYesReallyGetThemNow(); or something???

Meantime I ended up dropping back to 3.0.0
Thanks heaps

@cweiske
Copy link
Contributor

cweiske commented Sep 15, 2023

Commit that brought this breaking change was 89fd826

ClientObjectCollection.php enhancements, introduced getAll method

@vgrem vgrem added the bug label Oct 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants