Forum Discussion
Mike Jansen
Mar 21, 2017Iron Contributor
Rest api search query --- Lookup field issue
I have a document library which has a custom field "Label" this Label field is a lookup field (to a list) multiple values allowed. For example my documentlibrary: Title Label doc1 ...
- Mar 22, 2017Haven't tested it, but it should work with the $filter:
/_api/web/lists/GetByTitle('Documents')/items?$select=*,Label/Title&$expand=Label&$filter=Label/Title eq 'labelX'
Let us know how it goes.
Mike Jansen
Mar 21, 2017Iron Contributor
Hi Brent Ellis
Great!! This works:
https://blabla.sharepoint.com/sites/mike/label/_api/web/lists/getByTitle('Documents')/items?$expand=Label&$select=*,Label/Title
But now I need to get it to the next level. I want to filter on "LabelX"
Something like this:
https://blabla.sharepoint.com/sites/mike/label/_api/web/lists/getByTitle('Documents')/items?$expand=Label&$select=*,Label/Title&refinementfilters='Label/Title eq ('labelX')
Any suggestions?
Luis Mañez
Mar 22, 2017MVP
Haven't tested it, but it should work with the $filter:
/_api/web/lists/GetByTitle('Documents')/items?$select=*,Label/Title&$expand=Label&$filter=Label/Title eq 'labelX'
Let us know how it goes.
/_api/web/lists/GetByTitle('Documents')/items?$select=*,Label/Title&$expand=Label&$filter=Label/Title eq 'labelX'
Let us know how it goes.
- Mike JansenMar 22, 2017Iron Contributor
Hi Luis Mañez, and Brent Ellis,
Thank you both!! Found the solution.
Now make it some more dynamic but I can manage that.
For your information, this is my query:
https://blabla.sharepoint.com/sites/mike/label/_api/web/lists/getByTitle('Documents')/items?$select=*,Label/Title&$expand=Label&$filter=Label/Title eq 'labelX'&rowlimit=500
- Jun 26, 2017
Just to give a great article related to this question:
http://www.andrewconnell.com/blog/Applying-Filters-to-Lookup-Fields-with-the-SP2013-REST-API