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

LoadItemsByCamlQueryAsync not working with FolderServerRelativeUrl #1415

Open
1 task done
mortenfa opened this issue Mar 8, 2024 · 6 comments
Open
1 task done

LoadItemsByCamlQueryAsync not working with FolderServerRelativeUrl #1415

mortenfa opened this issue Mar 8, 2024 · 6 comments
Assignees
Labels
question Further information is requested

Comments

@mortenfa
Copy link

mortenfa commented Mar 8, 2024

Category

  • Bug

Describe the bug

When querying with LoadItemsByCamlQueryAsync on a semi large list (10000 items) querying a specific folder throws REST exception

Steps to reproduce

This is working

var viewXml = $@"<View Scope='RecursiveAll'><RowLimit Paged='TRUE'>{rowLimit}</RowLimit><Where><Eq><FieldRef Name='FSObjType' /><Value Type='Integer'>1</Value></Eq></Where><ViewFields><FieldRef Name='ID' /><FieldRef Name='FileRef' /></ViewFields></View>";

await sourceList.LoadItemsByCamlQueryAsync(new CamlQueryOptions() { ViewXml = viewXml, PagingInfo = nextPage }

This throws the item limit exception with the same viewXml

await sourceList.LoadItemsByCamlQueryAsync(new CamlQueryOptions() { ViewXml = viewXml, FolderServerRelativeUrl = sourceList.RootFolder.ServerRelativeUrl + "/Testfolder", PagingInfo = nextPage });

Expected behavior

Results

Environment details (development & target environment)

Visual Studio latest version

Additional context

Thanks for your contribution! Sharing is caring.

@jansenbe jansenbe self-assigned this Mar 13, 2024
@jansenbe jansenbe added the question Further information is requested label Mar 13, 2024
@jansenbe
Copy link
Contributor

@mortenfa : can you try to include the folder filtering in your CAML query, see #839 for some inspiration on how to do so. There's also a limitation with the used SharePoint API on special chars in the provided folder, so in my opinion it's anyhow better to implement this at CAML level. See also the notes of the related docs: https://pnp.github.io/pnpcore/using-the-sdk/listitems-intro.html#c-getting-list-items-via-the-loaditemsbycamlquery-approach

@jansenbe
Copy link
Contributor

@mortenfa : did you manage to get unblocked?

@mortenfa
Copy link
Author

not yet, I'll take a look in the weekend 😊👍

@mortenfa
Copy link
Author

mortenfa commented Mar 16, 2024

@jansenbe : Still not working. Getting this quite unusable error:

"SharePoint Rest service exception"

"Cannot complete this action. Please try again."

with this rowLimit:500 :

$@"<View Scope='RecursiveAll'> <RowLimit Paged='TRUE'>{rowLimit}</RowLimit> <ViewFields><FieldRef Name='FileDirRef' /><FieldRef Name='FileRef' /></ViewFields> <Query> <Where> <Or> <BeginsWith> <FieldRef Name='FileDirRef' /> <Value Type='Text'>{sourceList.RootFolder.ServerRelativeUrl}/_Documents</Value> </BeginsWith> <BeginsWith> <FieldRef Name='FileDirRef' /> <Value Type='Text'>{sourceList.RootFolder.ServerRelativeUrl}/_Emails</Value> </BeginsWith> <BeginsWith> <FieldRef Name='FileDirRef' /> <Value Type='Text'>{sourceList.RootFolder.ServerRelativeUrl}/Formalia</Value> </BeginsWith> </Or> </Where> </Query> </View>"

@bajce
Copy link

bajce commented Apr 16, 2024

@mortenfa did you try using LoadListDataAsStreamAsync (see #1044).

@mortenfa
Copy link
Author

@bajce : yes, tried that also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants