SharePoint 2013 REST API Query Items with cross site lookup column

Recently, I had to query items using SharePoint 2013 Rest API (/api/web/lists/getbytitle('')/items).  The problem that makes it hard is that it has a lookup column (Product) that looks up the items in a list from another web.  The typical $filter statement (/_api/web/lists/getbytitle('Pages')/items?$select=Title,Id&$filter=Product eq 1) doesn't work.

After searching online and a few trial/error, I got it working by using /_api/web/lists/getbytitle('Pages')/items?$select=Title,Id,ProductId&$filter=Product eq 1

The ProductId field is automatically added to the list by SharePoint when you have a lookup field.  You have to $select that ProductId and then you can filter the Product field.  It's weird but it works.

Comments

Popular posts from this blog

SharePoint 2013 - Working with Display Template for Content Search Web Part

How to Customize MOSS Site Manager (Site Content and Structure Page)

Add spell check dictionary in SharePoint 2010, SharePoint 2013, and Office 365