top of page

Create Custom People Search Page With Phone Number Attribute In SharePoint Online

We have a requirement from one of our clients. They want to modify the “peopleresults.aspx” page which is the default People Search Page provided by SharePoint OOTB.

SharePoint OOTB People Search page provides the following properties.

  1. Name

  2. Title

  3. Department

  4. About Me

Below is a screenshot of OOTB People Search result which will sync the above four properties from SharePoint User Profiles.

We want to show Phone Number with People Search. For that, make sure that Phone number is already synced from AD to SharePoint User Profiles. I assume that we have synced Phone Number already. First, we will modify OOTB template of People Search. For that, first, go to Search Center Site.

Ex -

1. Go to Site Setting > Web Designer Gallery >Master Page and Page Layout.

2. Click on "Display Templates".

3. Click on "Search".

4. Download a copy of “ItemPerson.html”.

5. Now, we will modify the code and rename the file.

A. Change Title and modify code in <mso:ManagedPropertyMapping>.


<title>Custom People Item Phone</title>  <mso:ManagedPropertyMapping msdt:dt="string">'AboutMe':'AboutMe','AccountName':'AccountName','BaseOfficeLocation':'BaseOfficeLocation','Department':'Department','HitHighlightedProperties':'HitHighlightedProperties','Interests':'Interests','JobTitle':'JobTitle','LastModifiedTime':'LastModifiedTime','Memberships':'Memberships','PastProjects':'PastProjects','Path':'Path','PictureURL':'PictureURL','PreferredName':'PreferredName','Responsibilities':'Responsibilities','Schools':'Schools','ServiceApplicationID':'ServiceApplicationID','SipAddress':'SipAddress','Skills':'Skills','UserProfile_GUID':'UserProfile_GUID','WorkEmail':'WorkEmail','WorkId':'WorkId','YomiDisplayName':'YomiDisplayName','WorkPhone':'WorkPhone','PhoneExtension':'PhoneExtension'</mso:ManagedPropertyMapping>  

B. Add the following code in <div id="Item_Person">


var has_wphone = !$isEmptyString(ctx.CurrentItem.WorkPhone);  

var has_ext = !$isEmptyString(ctx.CurrentItem.PhoneExtension);  

C. Add the following code in <div id="ContactInfo">


  1. <!--#_ if(has_wphone == true) { _#-->  

  2. <div id="WorkPhone">  

  3. <!--#_ var encodedwphone = $htmlEncode(ctx.CurrentItem.WorkPhone); 

  4. var displaywphone = Srch.U.getSingleHHXMLNodeValue(hhProps, "WorkPhone"); 

  5. if ($isEmptyString(displaywphone)) 

  6. displaywphone = encodedwphone 

  7. } _#-->  

  8. <div id="WorkPhoneValue" class="ms-srch ellipsis" title="_#= encodedwphone =#_">Phone: _#= displaywphone =#_ </div>  

  9. </div>  

  10. <!--#_ } _#-->  <!--#_ if(has_ext == true)  { _#-->  

  11. <div id="PhoneExtension">  

  12. <!--#_ var encodedext = $htmlEncode(ctx.CurrentItem.PhoneExtension); 

  13. var displayext = Srch.U.getSingleHHXMLNodeValue(hhProps, "PhoneExtension"); 

  14. if ($isEmptyString(displayext)) 

  15. displayext = encodedext 

  16. _#-->  

  17. <div id="PhoneExtensionValue" class="ms-srch ellipsis" title="_#= encodedext =#_"> _#= displayext =#_ 

  18. </div>  

  19. </div>  

  20. <!--#_ } _#--> 

6. Now, upload a modified file in Master Page Gallery>Display Template>Search Folder > Upload.

7. It will create a .js file automatically. Don’t forget to publish the page.

8. Now, we will create our custom people search page.  9. Go to Search center site > Settings  Ex:

10. Look and Feel > Page Layouts and site Templates.

11. Go to Site Contents > Pages Library.

12. Files> New Document >Article Page.

13. Give a name for the Page and click OK.

14. Edit a page that we have created > Edit People Search Core Web part

15. Select “Use a single item from a display template” > Select Uploaded Template > Save

16. Publish Page and check changes 17. Now you will be able to see Phone Number in People Search.


This is how we can add phone number attribute with search page and also how we can create our own custom Page.



bottom of page