Share via

Microsoft.SharePoint.Client.Site.GetItems(camlQry) returns 'folder' view version of data rather than list items

Anonymous
2023-08-10T10:34:37+00:00

I am querying a SharePoint Online List : /sites/MySite/Lists/People which I can see in the native UI contains 8 items with custom fields 'FirstName' , 'LastName', 'Manager'. These fields all have values in them.

I use the following code to access this list ( ctx & myList defined earlier) , expecting to get the 8 list items back.

       Microsoft.SharePoint.Client.CamlQuery camlQuery = new Microsoft.SharePoint.Client.CamlQuery();

          camlQuery.ViewXml =@"<View> <RowLimit>5000</RowLimit> </View>";

            Microsoft.SharePoint.Client.ListItemCollection items = myList.GetItems(camlQuery);

            ctx.Load(items);

            ctx.ExecuteQuery();

            foreach (Microsoft.SharePoint.Client.ListItem li in items)

            {

                =processLi(li);

            }

I notice that there are over 26 Listitems , the custom field names ( FirstName, LastName etc.. ) are all null, but there is a title field which is populated 'A' , 'B' , 'C' etc....

I suspect that this something to do with a Folder / Filtering feature in the list. Can anyone recommend a way to get the 8 list items. So far I have tried to use

Web.Lists.GetById(guidid); & getByTitle in case those behaved differently - but they dont

Thanks in Advance

Regards Richard

Microsoft 365 and Office | SharePoint | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2023-08-10T10:44:34+00:00

Just a little more digging & I found the answer : change the caml query to

"<ViewScope='RecursiveAll'>  

                               <RowLimit>5000</RowLimit> 

                          </View>";

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2023-08-10T12:04:39+00:00

    Hi Richard,

    Thanks for sharing the answer. To help members who may have the same concern, I will mark your reply as the answer.

    Sincerely, 

    George | Microsoft Community Moderator

    Was this answer helpful?

    0 comments No comments