pnp / pnpcore

The PnP Core SDK is a modern .NET SDK designed to work for Microsoft 365. It provides a unified object model for working with SharePoint Online and Teams which is agnostic to the underlying API's being called
https://aka.ms/pnp/coresdk/docs
MIT License
298 stars 192 forks source link

Missing Fields when using CAML Query and LoadListDataAsStreamAsync #1402

Closed mortenfa closed 7 months ago

mortenfa commented 7 months ago

Category

Describe the bug

When using CAML query and LoadListDataAsStreamAsync the result is missing fields. Looks like the same problem as https://github.com/pnp/pnpcore/issues/396 But the solution is not working for me.

The result only contains list custom fields. Not system fields . Specifically the FileLeafRef and FileRef fields.

I've also tried with LoadItemsByCamlQueryAsync with the same result

image

Steps to reproduce

This code

` $@"

                  <Query>
                     <Where>
                         <Gt>
                             <FieldRef Name='ID' />
                             <Value Type='Number'>10</Value>
                         </Gt>
                     </Where>
                 </Query>
             </View>";`

` var output = await sourceList.LoadListDataAsStreamAsync(new PnP.Core.Model.SharePoint.RenderListDataOptions() { ViewXml = viewXml, RenderOptions = RenderListDataOptionsFlags.ListData });

foreach (var listItem in sourceList.Items.AsRequested()) { if (listItem.FileSystemObjectType == PnP.Core.Model.SharePoint.FileSystemObjectType.File) { files.Add(listItem); } }`

Expected behavior

Access to the item fields including system fields

Environment details (development & target environment)

Windows 11, Visual Studio 2022, .NET 7 web api

Thanks for your contribution! Sharing is caring.

jansenbe commented 7 months ago

@mortenfa : using the current version of PnP Core SDK I'm seeing both fields returned for my test list

Using LoadListDataAsStream: image

Using LoadItemsByCamlQuery: image

jansenbe commented 7 months ago

@mortenfa : also tested this with a doc library and there both methods do return these fields as well. Do you see the same on smaller lists/libraries?

mortenfa commented 7 months ago

Strange. Yes, I am testing on a small doc lib with 150 items. I haven't implemented the Expression is this necessary?

jansenbe commented 7 months ago

@mortenfa : Expression is not required for the CAML query and not possible for the LoadListDataAsStream method. With "smaller" I meant returning only a few columns versus the 60+ from the screenshot

mortenfa commented 7 months ago

Ahh ok, I'll check 👍

mortenfa commented 7 months ago

@jansenbe : You're right, Just created an empty doc lib w/o content types enabled, Same query gives this

image

I may have to go another way since all our sites have the content types enabled.

Thanks

jansenbe commented 7 months ago

I don't think this is an SDK issue, it more feels like a limitation of the used APIs...you're good with closing this one for now @mortenfa ?

mortenfa commented 7 months ago

I think you're right, and sure, thanks again 👍