Forum Discussion
Sharepoint (online) search query - get properties of "people" field
I have, for testing, this query:
https://blabla.sharepoint.com/_api/search/query?querytext='ContentTypeId:0x0100AEC702D446F8F04696C2B7573837C451*'&trimduplicates=false&rowlimit=500&selectproperties='PersonName'
"PersonName" is a list colomn op type "People" and returns the name of a person. The query results are fine. I get all the names like "Joe Doe". But I also want to have some other properties of this "PersonName".
Is it possible to do this in this query or do I need to add an extra colom to my list (which I do not prefer). I tried this but that does not retun the "Account" of the "PersonName":
https://blabla.sharepoint.com/_api/search/query?querytext='ContentTypeId:0x0100AEC702D446F8F04696C2B7573837C451*'&trimduplicates=false&rowlimit=500&selectproperties='PersonName%2FAccount'
Doe not give me an error either.
Any suggestions?
Thanks, Mike
5 Replies
Hi Mike,
Could you try adding 'OWSUSER' after the property?
Like 'PersonNameOWSUSER'. There should be such a property created in crawled properties.
The result should contain:
user.name@contoso.com | User Name | [long identity] i:0#.f|membership|user.name@contoso.com
Anyway, it's better to check for managed and crawled properties, with your people picker field name, in CA (https://contoso-admin.sharepoint.com/_layouts/15/searchadmin/ta_listcrawledproperties.aspx?level=tenant) and try the guys which will be there.
--
Andrew
- Mike JansenIron Contributor
Andrew Koltyakov wrote:Hi Mike,
Could you try adding 'OWSUSER' after the property?
Like 'PersonNameOWSUSER'. There should be such a property created in crawled properties.
The result should contain:
user.name@contoso.com | User Name | [long identity] i:0#.f|membership|user.name@contoso.com
Anyway, it's better to check for managed and crawled properties, with your people picker field name, in CA (https://contoso-admin.sharepoint.com/_layouts/15/searchadmin/ta_listcrawledproperties.aspx?level=tenant) and try the guys which will be there.
--
Andrew
The OWSUSER option indeed works. It returns:
user.name@contoso.com | User Name | [long identity] i:0#.f|membership|user.name@contoso.com
That's one step forward. However, I use this query in powerBI to transfor the results to a table. But I only need the username. So how can I extract the username out of this string in PowerBI query editor?
- Mike JansenIron Contributor
Almost there ;-)
I used the split function to get the username (split on the first "@" from the left).
So that gives me "joe.doe"
Now I want to compare that with de current user (function username()). This gives me "domain\joe.doe". So I need to remove "domain\" in order to compare the two fields.
I'll try to find a solution for that issue as well.
Meawhile, all suggestions are appreciated.