I have a CSOM process that extracts metadata from a SharePoint Online site and generically traverses the lists. A certain Link-based list is throwing a
Microsoft.SharePoint.Client.ServerExeception of ‘Value does not fall within the expected range.’ when I include the
ListItem.DisplayName property. If I exclude the property, the list loads fine.
That leaves me with two questions for the SharePoint StackExchange community:
- Is this expected behavior? I would have thought the
DisplayNameproperty would always exist on a
- Is there a way for me to check whether a list contains the
DisplayNameproperty so I can choose when to request it?
Here is my relevant code:
// This CamlQuery appears to be irrelevant to the error, but is included as a representation CamlQuery camlQuery = new CamlQuery(); camlQuery.ViewXml = "<View Scope="RecursiveAll"><ViewFields><FieldRef Name='WorkflowVersion' /></ViewFields></View>"; List list = clientContext.Web.Lists.GetByTitle("My List"); clientContext.Load(list); clientContext.ExecuteQuery(); ListItemCollection listItems = list.GetItems(camlQuery); clientContext.Load( listItems, i => i.IncludeWithDefaultProperties( p => p.Id, p => p.DisplayName, // Including this property causes the "Value does not fall within the expected range." error p => p.Folder ) ); clientContext.ExecuteQuery(); // Error is thrown here...