2

I have a REST query that looks like this

/_api/lists/getbytitle('MainList')/items?$select=Title,LookupField/Id,LookupField/Title&$expand=LookupField

That works fine. But when I try to pull another field from the lookup list, I get an error. This query:

/_api/lists/getbytitle('MainList')/items?$select=Title,LookupField/Id,LookupField/Title,LookupField/CustomField&$expand=LookupField

Results in:

The query to field 'LookupField/CustomField' is not valid.

I should point out that if I try to pull in a standard field such as LookupField/Modified or LookupField/Created it works fine. It's only when I try to select a custom field that I get this error. Is that a limitation of the SharePoint API?

  • What is the type of your custom column? – Sergei Sergeev Dec 22 '16 at 17:51
4

When creating lookup field, you can select which field from source list you want to show. The number of such fields is limited by field type. For example you can create a lookup with lookup field pointed only to the following field types:

  • Single line of text
  • Date and Time
  • Number

Thus in your REST query you can select additional fields only with aforementioned field types.
For example you have a list Category with fields Title, Id, Active (custom Yes\No field). You created a lookup to Category in your other list.
Now what you have:

$select=category/Id,category/Title&$expand=category - works

and

$select=category/Id,category/Title,category/Active&$expand=category - doesn't work because Yes\No is unsupported field type for lookup.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.