Mar 21 2017 07:46 AM - edited Mar 21 2017 07:58 AM
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 labelY, labelX
doc2 labelX
doc3 labelY, labelZ
Now I want to create a rest query to filter documents by Label
So far I have this:
https://blabla.sharepoint.com/sites/mike/label/_api/web/lists/getByTitle('Documents')/items?&select='Label%2cTitle%2cType'&refinementfilters='Label:contains('labelX')'
However, this gives me all documents in the library. So no filtering.
And when I check the xml result "Label" is referred as an ID to the list and not as "labelX"
What is wrong in my approach?
Thanks, Mike
Mar 21 2017 08:13 AM
Mar 21 2017 08:23 AM
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?
Mar 22 2017 12:29 AM
SolutionMar 22 2017 01:46 AM - edited Mar 22 2017 02:16 AM
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 09:01 AM
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
Mar 22 2017 12:29 AM
Solution