0

I have a lookup list that contains a choice field.

I'm trying to retrieve it's values using rest

Expand= "list" Select= "list/ChoiceField"

I get

The query to field 'list/ChoiceField' is not valid."

1

Consider the following scenario:

List A with columns:

  • Title (Single Line Text)
  • ColumnA (Single Line Text)
  • ColumnB (Choice)

and

List B with columns:

  • Title (Single line of Text)
  • ColumnOne (Single line of Text)
  • ColumnX (Lookup From List A, column A mapped)

So the REST Query for List B would be:

https://<site url>/_api/web/lists/getbytitle('ListB')/Items?$expand=ColumnX&$select=Title,ColumnX,ColumnX/ColumnB

EDIT

The above concept doesnt work on choice type of column. For choice type column, you can use below concepts.

Concept 1: Use of hidden column (text), with Workflow/ER.

In this case, use Event Receiver (for SPO Webhook) or Workflow to read the value of choice column and update the hidden column with these values.
Pros: You can use the above query to expand the hidden column.
Cons: You need to have another steps in between, to convert content of choice column to text column.

Concept 2: Use List Field endpoint, instead of List Item endpoint. If you know the item ID of ListB item, then you can directly hit field endpoint to get all the column values of Lookup ListA.
Pros: No extra conversion method required as listed in concept 1.
Cons: Low on performance, as you require the item ID in this case.

Syntax:

https://<site url>/_api/web/lists/getbytitle('ListB')/Items(<item_id>)/ColumnX
  • 1
    Try what you said on a multi-choice field and let me know if that works for you. – Batman Jun 13 at 5:59
  • My bad, I havent tried it before. I updated the answer to add two concepts (test this time). Check your requirement if they fit and solve your issue. – ThinkB4Code Jun 14 at 18:42

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.