A client recently had a request to provide a search users by department with the department list pre-populated in a drop-down menu:
So the question was:
“How can I query the Department managed property values for People to populate the drop-down menu?” (which would be cool if it autocompleted.. for another day maybe!)
The answer is: Using the Search REST API with a single GET query:
To break down the above URL:
QueryText=’*’ – Get EVERYTHING
ContentClass=’urn:content-class:SPSPeople’ – Only People
selectproperties=’Department’ – Retrieve Department property (Edit: No surprise @mikaelsvenson is right this is not strictly necessary unless you need this in the results, but we don’t care about them for now!)
Refiners=’Department’ – This is the important element; retrieve all Department refiners
RowLimit=0 – We don’t actually want any results, we just want to know what all the refiners would have been so we can fill our drop-down menu
The result is XML which you can do what you want with – note that even with 0 RowLimit the refiners are still retrieved – bonus!
Hope that helps! 🙂
Leave a Reply