none
Show "Created" datetime on custom search display template RRS feed

  • Question

  • I created custom search results display template to show list items from specific content type. It show data in table format displaying OOTB fields like Modified, Created and other custom managed properties. All fields are returning data correctly except "Created" field which returns blank. I am able to use it as refiner and it filters out search result items correctly, which shows data is crawled and mapped correctly. Is there anything additional steps I need to do for displaying created date/time for list items on custom display template?

    Few details about custom template:

    • Custom display template is based of Item_Default
    • Managed property "Created" is defined under ManagedPropertyMapping
    <mso:ManagedPropertyMapping msdt:dt="string">'Title':'Title','Path':'Path','linkURL':'linkURL','Description':'Description','Created':'Created','EditorOWSUSER':'EditorOWSUSER','LastModifiedTime':'LastModifiedTime'
    • data is displayed along with other properties

    <div class="mr-table-cell">_#= ctx.CurrentItem.Created =#_</div>

    • Managed property mappingfrom search schema


    MK Sin


    • Edited by Mo Key Tuesday, June 30, 2020 4:57 PM Images were taken down so added property mapping and missing image back again
    Tuesday, June 30, 2020 4:00 PM

Answers

  • Hi Mo Key,

    That's really good. I am glad to see this gets resolved. I am also educated by following words from that blog:

    If possible could you please mark the solution as answer so that others who stuck in similar questions could get answered quickly?

    Best Regards,

    Baker Kong


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

    SharePoint Server 2019 has been released, you can click  here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.


    Thursday, July 2, 2020 1:23 AM

All replies

  • Hi Mo Key,

    When i print 'ctx.CurrentItem' , there is a property 'Write" that shows the created time. You may try to directly use it. 

    Thanks

    Baker Kong


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

    SharePoint Server 2019 has been released, you can click  here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Wednesday, July 1, 2020 5:37 AM
  • Hi Baker,

    Thank you for your response. Write property is actually mapped to LastModifiedTime so it is not returning Created Time. But using same technique of printing ctx.CurrentItem, I was able to further troubleshoot the issue and was able to resolve it by mapping additional crawled properties - Created, ows_Created,ows_Created_x0020_Date and CreatedDateTime and ran full crawl.

    Anyone out there who has not done this before, I added code below on item display template and result is displayed on console of developer tool. referenced from sadomovalex's blog

       1: for (var p in ctx.CurrentItem)
       2: {
       3:     console.log(p + ":" + $getItemValue(ctx, p));
       4: }
    Again, thank you for your help.

    MK Sin

    Wednesday, July 1, 2020 4:02 PM
  • Hi Mo Key,

    That's really good. I am glad to see this gets resolved. I am also educated by following words from that blog:

    If possible could you please mark the solution as answer so that others who stuck in similar questions could get answered quickly?

    Best Regards,

    Baker Kong


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

    SharePoint Server 2019 has been released, you can click  here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.


    Thursday, July 2, 2020 1:23 AM