Contents
Here’s the problem: When you add a lookup field to a list in SharePoint, you can’t filter by the name of the item in the lookup column when using the REST API. The reason is simple: the value isn’t exposed the way you might expect it. Consider the following scenario: You have two lists (1) Companies and (2) Employees.
How does the OData filter work in SharePoint?
To get more from the OData Filter Query you should understand what you’re filtering. Not only the data and its type, but also how is the column implemented in SharePoint. Once you understand that the lookup data is stored as an item ID to the lookup list, building the filter itself is a simple task.
Please Sign up or sign in to vote. I have a SharePoint list as below. col1 is a lookup field. I want to use Rest API and filter the list on a col1 in such a way that even if i give part of the string, it should search the record. “, but no luck. When i replace substring and use filter = lookup/col eq ‘value’ , i was able to search.
Is there a way to filter columns in SharePoint?
The Filter Query above will return only items with the same lookup value. Just make sure you use the internal name of the lookup column. To get more from the OData Filter Query you should understand what you’re filtering. Not only the data and its type, but also how is the column implemented in SharePoint.
SharePoint Lookup columns are very much helpful when you want to display data which are presented in a separate list. In the large enterprise, there are list data which may be related to another list in SharePoint Online or SharePoint 2013. In those cases lookup columns are ideal.
How to create a rest column in a lookup field?
Consider your lookup column name as ” Field1LUP ” of ” List1 ” and ” Title ” field of ” List2 ” is source to lookup field. The REST API and OData request parameters can be used to request additional information from a lookup field.
If we need to get the employee name and id as well as the department name and id, we can use this GET request: This gets the employee ( DepartmentId, Name, and Id). We expand the Department look up field and read the department name (Department/Name).