Search code examples
c#sharepointdisplay-templates

SharePoint 2013 People:Assistant returns empty when created as Managed Property


If I create a Managed Property that points to the People:Assistant property it always returns an empty string if set to text or undefined if set to binary.

The Assistant property is of type Person and I want to use the properties to create a link to the Assistant profile.

What I have done is: Fill out the Assistant field in a user Profile

Create a new Managed Property called assistant

  1. Type: Text
  2. Retrievable: true
  3. Mapping: People:Assistant

In the display template add Assistant to the managed properties Save everything and for good measure do a crawl.

Check that Assistant is set to another Person on the profile

Debug the display template and check ctx.CurrentItem.Assistant. It returns "".

If I set the Managed Property type to binary then it returns undefined

I have also tried ctx.CurrentItem.Assistant[0] or ctx.CurrentItem.Assistant["PreferredName"]

Can anyone point me in the right direction of how I would either return the Person object as a managed property or get a reference to it so that I can create a new Person object and access the properties


Solution

  • Finally found out what I was missing. When setting up the managed property, set it to text and click the Advanced Searchable Settings and select PeopleIdx

    Do a full crawl and the managed property will return <domain>\<username> which can be used to create a link to the user.

    All I have to do now is work out how to return the users display name from the domain address :-)