I have a list with a relatively large number of person columns in SharePoint Online and am having an issue where I am able to query certain person columns but not others and am unable to come up with an explanation about why or how to solve this.
I am aware that SharePoint Online imposes a limit on the number of lookups/person columns that can be retrieved in a single query, but I am having this issue even if I try to query a single column.
In order to reproduce the issue and illustrate what I am doing, I have made this function:
function queryList(queryValue, selectColumn) { var context = SP.ClientContext.get_current(); var list = context.get_web().get_lists().getByTitle('Teams'); var camlQuery = new SP.CamlQuery(); var viewXml = `<View Scope='RecursiveAll'> <Query> <Where> <Eq><FieldRef Name='MfgLoc' /><Value Type='Text'>$ {queryValue}</Value></Eq> </Where> </Query> </View>`; camlQuery.set_viewXml(viewXml); var listItems = list.getItems(camlQuery); context.load(listItems, `Include($ {selectColumn})`); context.executeQueryAsync(() => console.log('done'), (_, e) => console.error(e.get_message())); }
This basically just queries the list, filtering a single text column on a single value, and retrieving one column.
For certain columns, this works fine:
queryList('NY', 'LOGISTICS_x002d_PP'); // completes successfully
For others, it doesn’t:
queryList('NY', 'DISTRIBUTION_x002d_PP');
The latter fails with an unhelpful SharePoint internal error: Value does not fall within the expected range.
I have also observed that if I filter the query such that it doesn’t match any rows, it completes without error, even when trying to retrieve the same column:
queryList('NF', 'DISTRIBUTION_x002d_PP'); // completes successfully because no rows have an MfgLoc of NF
There seems to be no significant difference between the columns where this succeeds vs. the ones where it fails except that it seems that it succeeds for the first nine person columns that were originally created in the list and fails for all other person columns (so, the 10th person column created and onwards).
Querying these columns using Lists.asmx or the REST API works just fine, but fails in JSOM no matter what I do.
Has anyone else run across this issue?