Office information visible on people search results?

I have tried to get Office information visible in people search results page By editing DisplayTemplate like follows; added these lines but it doesn't become visible. What might be wrong:


<!--#_                                         if(has_office == true) {
_#-->
                                            <div id="BaseOfficeLocation">


<!--#_                                         var encodedoffice = $htmlEncode(ctx.CurrentItem.BaseOfficeLocation);


                                                var displayoffice = Srch.U.getSingleHHXMLNodeValue(hhProps, "BaseOfficeLocation");


                                               if ($isEmptyString(displayoffice)) { displayoffice = encodedoffice }


_#-->
                                                <div id="BaseOfficeLocationValue" class="ms-srch-ellipsis" title="_#= encodedoffice =#_"> _#= displayoffice =#_ </div>
                                            </div>
<!--#_                                         }
_#-->


<!--#_                                         if(has_office2 == true) {
_#-->
                                            <div id="Office">


<!--#_                                         var encodedoffice2 = $htmlEncode(ctx.CurrentItem.Office);


                                                var displayoffice2 = Srch.U.getSingleHHXMLNodeValue(hhProps, "Office");


                                               if ($isEmptyString(displayoffice2)) { displayoffice2 = encodedoffice2 }


_#-->
                                                <div id="OfficeValue" class="ms-srch-ellipsis" title="_#= encodedoffice2 =#_"> _#= displayoffice2 =#_ </div>
                                            </div>
<!--#_                                         }
_#-->

September 2nd, 2015 12:55pm

Hi Freedomic,

I need to verify the things below with you first:

  1. Was the Office another managed property created in your environment and the mapping added to the <mso:ManagedPropertyMapping> part?
  2. Did you declare the variable has_office?
  3. Please make sure that the value for the Office Location has been filled in user profiles. Because when it has value, the condition if(has_office == true) is met.

More reference about modifying search display template:

http://www.ableblue.com/blog/archive/2013/06/05/introduction-to-sharepoint-2013-display-templates/

Best regards,

Victoria

Free Windows Admin Tool Kit Click here and download it now
September 4th, 2015 2:15am

1. It's not, it's supposed to be OOB property in AD.

2. I declared has_office2 as    

var has_office2 = !$isEmptyString(ctx.CurrentItem.Office);

So, I have has_office and has_office2 in use. Both are visible in my code snippet above.

3. The value Office should be filled in AD and it's visible on profile page.

September 8th, 2015 6:37am

Hi Freedomic,

It seems that the managed property is OfficeNumber, so you need to use ctx.CurrentItem.OfficeNumber in your code.

And please also add the property mapping for the OfficeNumber to the to the <mso:ManagedPropertyMapping> part.

Best regards,

Victoria

Free Windows Admin Tool Kit Click here and download it now
September 9th, 2015 2:28am

Indeed it works now with OfficeNumber. Amazing.

I tried before to search for the property name on the net but didn't find it, only "Office".

Thanks for reminding about mso part.

Thank you very much!

September 10th, 2015 1:54am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics