5

I have 2 lists, List1 and List2.

List1 is a list of items which has an ID lookup to items in List2

I have a query which queries an item in List1 and then returns expanded values from the associated id in List2

My query looks like this:

_api/web/lists/getbytitle('List1')/items?$expand=List2&$select=ID,List2/ID,List2/URL,List2/Title

And that has been working fine. Up until I added a Yes/No field to List2, and tried to get that expanded value.

Now with my new query:

_api/web/lists/getbytitle('List1')/items?$expand=List2&$select=ID,List2/ID,List2/URL,List2/Title,List2/YesNoField

I get the error

The query to field 'List2/YesNoField' is not valid.

It appears that the Rest API call is not happy expanding on a boolean type column.

Is there any way to make this work, or any suggested work arounds?

  • 1
    If expand have the same limitations as ProjectedFields, boolean is not valid. A possible workaround used then is adding a calculated field with the value of your boolean field, and project to that. Maybe that works for expand too – Anders Aune Nov 4 '15 at 10:58
  • Didnt think of that workaround, and it works wonders for me (expanding on the new 'YesNoFieldResult' calculated to text column). :) Thanks Anders! – Simon Nov 4 '15 at 11:04
5

Based off Anders suggestion, I ended up adding a second column field which is a 'text returning' calculated field off my boolean field (as it is not apparently supported for expanding on).

This allowed me to get the value on expansion in my query.

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.