none
How To Add Phone Number to "People Named" result RRS feed

  • Question

  • Hello SharePoint Fam,

    I was able to get Work Phone field added to the actual people results display, but I am not sure how to actually get Work Phone added to default "Everything" Local SharePoint Results where it says "People Named".  It shows Name, Position Title & Department and I am wanting to just add the Work Phone field as well.  Could someone tell me what needs tweaked to make the Work Phone appear as well?

    Thanks N Advance For Any Help

    Wednesday, March 22, 2017 1:45 PM

All replies

  • Hi,

    Here is the workaround for your reference.

    Add the AddPostRenderCallback to Item_Default.html.

     

    window.runCheck = false;
            AddPostRenderCallback(ctx, function () {
                if (!window.runCheck) {                                
                    if (ctx.ListData.ResultTables && ctx.ListData.ResultTables.length>0) {
                        var firstData = ctx.ListData.ResultTables[0].ResultRows[0];
                        if (firstData.WorkPhone&&firstData.WorkPhone != "") {
                            var phoneDiv = document.createElement("div");
                            phoneDiv.className = 'phoneDiv';
                            var t = document.createTextNode("Phone:" + firstData.WorkPhone);
                            phoneDiv.appendChild(t);
                            document.getElementById("NameField").appendChild(phoneDiv);
                            //alert(firstData.WorkPhone);
                            window.runCheck = true;                    }
                    }
                }
            }); 

    Result:

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Thursday, March 23, 2017 6:43 AM
  • Thanks for response, the field is called Work Phone so should I place a space for Work Phone in script and should I put this script between <script> tags? thanks!
    Tuesday, June 20, 2017 4:52 PM
  • Hi,

    You need update the default display template( in case you use default display template in your search result page).

    You could use SharePoint Designer to open the template.

    You could find the path below.

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Wednesday, June 21, 2017 1:23 AM
  • Hi Lee,

    Finding the display template file is no problem at all.  I've found the file and added your script but search is still not showing the "Work Phone" field.  The Work Phone field has a space in it.  Do I need to tweak the script so that it sees the space in the field? thnx

    Wednesday, June 21, 2017 1:41 PM
  • Hi,

    Seems I forgot to post some steps.

    Try with below steps:

    Add 'WorkPhone':'WorkPhone' to <mso:ManagedPropertyMapping msdt:dt="string"> of item_person.html(backup before updating).

    Go to Site Settings  : Manage Result Types

    Copy Person result type.

    Don’t change anything and Save in new window.

    Result:

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Wednesday, June 28, 2017 12:41 PM
  • Thanks so much for responding, I totally missed this response somehow, In the item_person file where exactly do I add "'WorkPhone':'WorkPhone' to <mso:ManagedPropertyMapping msdt:dt="string"> 
    Wednesday, June 27, 2018 2:00 PM