2

In my SharePoint site, I have another subsite. On the top level site, there is a list to store 'document type'. Within the subsite, I have a document library which lookup the 'document type' list.

I need to get the lookup field values for the document library item which I query through REST API. The lookup field is 'Az_DocumentType'

Initially I got the document type id using the below sample:

http://MY_SUB_SITE/_api/web/lists/getByTitle('Document Library')/items(3)?$select=Az_DocumentTypeId

However when I use the below code to get the value of the field using 'expand' I get the below error.

Rest call:

http://MY_SUB_SITE/_api/web/lists/getByTitle('Document Library')/items(3)?$select=Az_DocumentType/Id&$expand=Az_DocumentType/Id

Error in Postman window:

The field 'Az_DocumentType' is not supported in the query. The lookup list is in another web.

Is there a way to get lookup field values as this in one go?

2

It doesn't look like this is possible. I just tried creating a site column as a lookup field in the site collection root, then I added it to a list in a child site. The field names are correct in the list, i.e., there's no weird appended root site name or ID in the column name for the REST query, but I still get:

<m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<m:code>-1, Microsoft.SharePoint.SPException</m:code>
<m:message xml:lang="en-US">
The field 'Lookup_x0020_Field_x0020_Name' is not supported in query. The lookup list is in another web.
</m:message>
</m:error>

when I run a query against it.

You could run a separate query to get the contents of the lookup list in the parent site and match them up by ID, because you can still get the lookup item ID without trying to expand the lookup. But that's not nearly as making the server do it for you with $expand.

0

No, you can only process only one web in a single REST call.

First of all, how did you refernce a lookup field from a list that is present in another web? Iguess that should be a custom feature using cross site publishing.

But REST cannot be used in that way. Only if your 'Document Library' and the lookup list is present in the same web you may get the lookup object.

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.