3

I am working on a Team site collection inside sharepoint enterprise server 2013 and I have added a Content Search web part. Now I wanted to show the CreatedBy field inside my content search web part. So I find that the intended managed property is "AuthorOWSUSER", as follow:-

enter image description here

I chose this specific managed property since this managed property shows the original creator of the item, unlike the "Author" managed property which shows the creator + any user who modifies the item..

The only issue I faced with the "AuthorOWSUSER" is that I am using a custom display template , and this custom display template uses the managed property name as a title inside the generated list as follows:-

enter image description here

So i wanted to rename the "AuthorOWSUSER" to something which is more user friendly. I did the following steps to create a new copy of the "AuthorOWSUSER" managed property, with a new name. I went to "Central Admin">>"Search Service">>"Search Schema">>"Add new managed property">> I named it "Creator" and I defined the same setting as which is provided inside the "AuthorOWSUSER" . But the result I got for the new managed property is that the whole user details such as user id , domain name will be shown , unlike the "AuthorOWSUSER" which will only show "FirstName LastName",

enter image description here

So can anyone advice on this please ? How to create a copy of the "AuthorOWSUSER" with new name ? I know that I can rename the original "AuthorOWSUSER" to be "Creator" but I always try not to rename or remove any things which is provided by default inside SharePoint , such as the "AuthorOWSUSER" managed property..

Hint. Now i have noted that inside my new managed property I am unable to change the "advance searchable settings". Now inside the built-in "AuthorOWSUSER" the full-text index is set the "default" , while on my new managed property it is set to "peopleidx" and I am unable to change it ,so could this be the problem, that on the new managed property the full name details (including id, domain, etc) will be shown ? enter image description here

1 Answer 1

4
+25

enter image description here

there are 2 options -

1) in your custom display template, find the ManagedPropertyMapping section, in that you can add/edit the mapping as below. Its called mapping the property:

  'Author':'AuthorOWSUser'

This should change the title. Its like display name / internal name mapping.

2) or in the display template code, you can extract the author value as follows:

if (!$isEmptyString(ctx.CurrentItem.AuthorOWSUSER))
        {
            author = Srch.U.getDisplayNameFromAuthorField(ctx.CurrentItem.AuthorOWSUSER);
        }

or like this

 var author = $getItemValue(ctx, "Author");

This will give you the correct author value.

Edit :

Based on the comments, i am adding the below code which will rename AuthorOWSUSER in the title:

in your display template , find this line and change it as below:

        // Show the properties that aren't empty
    for(var i = 1; i <= 10; i++) { 
        var property = $getItemValue(ctx, String.format("Property {0}", i));
        if(property.managedPropertyName !== String.format("Property {0}", i)) {
            var propertyName = typeof propertyNames[property.propertyLookupName] === "undefined" ? property.managedPropertyName : propertyNames[property.propertyLookupName];
            if(propertyName =="AuthorOWSUSER"){
                propertyName = "Author";
            }
12
  • now when you say to modify the display template , you are referring to exporting the content search web part itself ,and then modify it (modify the .webpart file)? or you are talking about modifying the display template (.html) which is found inside my "/_catalogs/masterpage/Display Templates/Content Web Parts/" ?
    – John John
    Commented Oct 11, 2016 at 12:32
  • 1
    modifying the html file in the "/_catalogs/masterpage/Display Templates/Content Web Parts/" folder Commented Oct 11, 2016 at 12:36
  • but the .html file is general templete with lines to add managed properties, it contain the ability to select the managed property names ... so i will not find AuthorOWSUSER explicitly defined there ...is this correct?
    – John John
    Commented Oct 11, 2016 at 12:44
  • but inside my display template the ManagedPropertyMapping section looks as "<mso:ManagedPropertyMapping msdt:dt="string">ListID','ListItemID','ContentTypeId','Link URL':'Path','Property 1':'Title','Property 2':'','Property 3':'','Property 4:'','Property 5':'','Property 6':'','Property 7':'','Property 8':'','Property 9':'','Property 10':'','FileExtension','SecondaryFileExtension'</mso:ManagedPropertyMapping>" so i can not find explicit occurance for the "AuthorOWSUSER"!!
    – John John
    Commented Oct 11, 2016 at 12:54
  • but i think there is a grey section inside the display template which i can modify . as in my template i always get the first property as "Title" and the second property as "created by" as define inside this section.. but not sure how i can specify if the title is "AuthorOWSUSR " to change to "Author" ??
    – John John
    Commented Oct 11, 2016 at 12:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.