0

I created a very basic display template to show some properties for a content type, Basically it says, if content type ="Tax Invoice", use this diplay template.

All the managed properties exist and are correctly spelled.

The only thing I can think of is maybe some of them might be empty or null and I need to write javascript logic for that?

If you think that might be the reason, can you please show me an example for my display template below.

<html xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"> 
<head>
<title>Item Tax Invoice</title>

<!--[if gte mso 9]><xml>
<mso:CustomDocumentProperties>
<mso:TemplateHidden msdt:dt="string">0</mso:TemplateHidden>
<mso:MasterPageDescription msdt:dt="string">Displays the default result item template.</mso:MasterPageDescription>
<mso:ContentTypeId msdt:dt="string">0xxx</mso:ContentTypeId>
<mso:TargetControlType msdt:dt="string">;#SearchResults;#</mso:TargetControlType>
<mso:HtmlDesignAssociated msdt:dt="string">1</mso:HtmlDesignAssociated>
<mso:ManagedPropertyMapping msdt:dt="string">'Title':'Title','Path':'Path','Description':'Description','EditorOWSUSER':'EditorOWSUSER','LastModifiedTime':'LastModifiedTime','CollapsingStatus':'CollapsingStatus','DocId':'DocId','HitHighlightedSummary':'HitHighlightedSummary','HitHighlightedProperties':'HitHighlightedProperties','FileExtension':'FileExtension','ViewsLifeTime':'ViewsLifeTime','ParentLink':'ParentLink','FileType':'FileType','IsContainer':'IsContainer','SecondaryFileExtension':'SecondaryFileExtension','DisplayAuthor':'DisplayAuthor','JobCodes':'JobCodes','BillNumber':'BillNumber','BillDate':'BillDate','BillToDate':'BillToDate','Amount':'Amount','DueDate':'DueDate'</mso:ManagedPropertyMapping>
<mso:HtmlDesignConversionSucceeded msdt:dt="string">True</mso:HtmlDesignConversionSucceeded>
<mso:HtmlDesignStatusAndPreview msdt:dt="string">https://be-xx.xx.x.xx.com/sites/billing/_catalogs/masterpage/Display Templates/Search/Item_TaxInvoice.html, Conversion successful.</mso:HtmlDesignStatusAndPreview>
<mso:CrawlerXSLFile msdt:dt="string"></mso:CrawlerXSLFile>
<mso:HtmlDesignPreviewUrl msdt:dt="string"></mso:HtmlDesignPreviewUrl>
</mso:CustomDocumentProperties>
</xml><![endif]-->
</head>
<body>
    <div id="Item_TaxInvoice">
<!--#_ 
        if(!$isNull(ctx.CurrentItem) && !$isNull(ctx.ClientControl)){
            var id = ctx.ClientControl.get_nextUniqueId();
            var itemId = id + Srch.U.Ids.item;
            var hoverId = id + Srch.U.Ids.hover;
            var hoverUrl = "~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_Word_HoverPanel.js";
              $setResultItem(itemId, ctx.CurrentItem);
            if(ctx.CurrentItem.IsContainer){
                ctx.CurrentItem.csr_Icon = Srch.U.getFolderIconUrl();
            }
            ctx.currentItem_ShowHoverPanelCallback = Srch.U.getShowHoverPanelCallback(itemId, hoverId, hoverUrl);
            ctx.currentItem_HideHoverPanelCallback = Srch.U.getHideHoverPanelCallback();
            var dueDate = new Date($getItemValue(ctx, "DueDate"));
            var billDate = new Date($getItemValue(ctx, "BillDate"));

_#-->
            <div id="_#= $htmlEncode(itemId) =#_" name="Item" data-displaytemplate="TaxInvoiceItem" class="ms-srch-item" onmouseover="_#= ctx.currentItem_ShowHoverPanelCallback =#_" onmouseout="_#= ctx.currentItem_HideHoverPanelCallback =#_">
                _#=ctx.RenderBody(ctx)=#_
                <p><b>Jobs: </b> _#= ctx.CurrentItem.JobCodes= #_ </p>
                <p><b>Bill Number: </b> _#= ctx.CurrentItem.BillNumber =#_ </p>
                <p><b>Bill date: </b>_#= billDate.format("dd/MM/yyyy") =#_  </p>
                <p><b>Bill To Date: </b> _#= billToDate.format("dd/MM/yyyy") =#_ </p>
                <p><b>Amount: </b> _#= ctx.CurrentItem.Amount =#_ </p>
                <p><b>Due date: </b> _#= dueDate.format("dd/MM/yyyy") =#_ </p>
                <div id="_#= $htmlEncode(hoverId) =#_" class="ms-srch-hover-outerContainer"></div>
            </div>

<!--#_ 
        } 
_#-->
    </div>
</body>
</html>

Component and System=Query1-cbdbeb60-6b87-4f94-8bfa-7ed8baf7a3c1, Correlation ID=9d06819c-4647-c05e-bf84-fd27fad8a135, Tenant ID=00000000-0000-0000-0000-000000000000 Error code=, Flow Name=Microsoft.SharePointSearchProviderFlow, Operator Name=ParserExecutor, Message=The processing of item fails with error Object reference not set to an instance of an object.

Microsoft.Ceres.InteractionEngine.Component.FlowHandleRegistry : Exceptions occurred when evaluating the flow. Microsoft.Ceres.Evaluation.DataModel.EvaluationException: Evaluation failed in operator IndexLookupExecutor of type IndexLookupExecutor ---> System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Office.Server.Search.Query.Pipeline.Processing.DisplayResults.RetrieveRecords(IList1 docIds, IList1 fieldsList, IQueryPipelineService queryPipelineService, IMarsLookupService lookup, Int64 generationId, Int64 timeout, Guid correlationId, Guid tenantId, Guid siteCollectionId, String docIdFieldName) at Microsoft.Office.Server.Search.Query.Pipeline.Processing.ResultTypeCalculatorEvaluator.ResultTypeCalculatorRecordSet.RetrieveDisplayFields(Guid correlationId, Guid searchApplicationId) at Microsoft.Office.Server.Search.Query.Pipeline.Processing.ResultTypeCalculatorEvaluator.ResultTypeCalculatorRecordSet.DoMoveNext() at Microsoft.Ceres.Evaluation.Processing.RecordSets.RecordSet.MoveNext() at Microsoft.Ceres.Evaluation.Processing.RecordSets.RecordSet.d__0.MoveNext() at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source) at Microsoft.Office.Server.Search.Query.Pipeline.Executors.IndexLookupExecutor.ExecuteCore(IRecord inputRecord) at Microsoft.Office.Server.Search.Query.Pipeline.Executors.QueryPipelineFlowExecutor.Execute(IRecord inputRecord) at Microsoft.Office.Server.Search.Query.Pipeline.Processing.ExecutorProducer1.ProcessRecord(IRecord record) at Microsoft.Ceres.Evaluation.Processing.Producers.ProducerRecordSetSink.Put(IRecord record) at Microsoft.Ceres.Evaluation.Engine.ErrorHandling.HandleExceptionRecordSetSink.DoWithoutTryCatch(IRecord record) at Microsoft.Ceres.Evaluation.Processing.Producers.ProducerRecordSetSink.PushToOutput() at Microsoft.Ceres.Evaluation.Processing.Producers.ProducerRecordSetSink.Put(IRecord record) at Microsoft.Ceres.Evaluation.Engine.ErrorHandling.HandleExceptionRecordSetSink.DoWithoutTryCatch(IRecord record) at Microsoft.Ceres.Evaluation.Processing.Producers.ProducerRecordSetSink.PushToOutput() at Microsoft.Ceres.Evaluation.Processing.Producers.ProducerRecordSetSink.Put(IRecord record) at Microsoft.Ceres.Evaluation.Engine.ErrorHandling.HandleExceptionRecordSetSink.DoWithoutTryCatch(IRecord record) at Microsoft.Ceres.Evaluation.Processing.Producers.ProducerRecordSetSink.PushToOutput() at Microsoft.Ceres.Evaluation.Processing.Producers.ProducerRecordSetSink.Put(IRecord record) at Microsoft.Ceres.Evaluation.Engine.ErrorHandling.HandleExceptionRecordSetSink.DoWithoutTryCatch(IRecord record) at Microsoft.Ceres.Evaluation.Processing.Producers.ProducerRecordSetSink.PushToOutput() at Microsoft.Ceres.Evaluation.Processing.Producers.ProducerRecordSetSink.Put(IRecord record) at Microsoft.Ceres.Evaluation.Engine.ErrorHandling.HandleExceptionRecordSetSink.DoWithoutTryCatch(IRecord record) at Microsoft.Ceres.Evaluation.Processing.Producers.ProducerRecordSetSink.PushToOutput() at Microsoft.Ceres.Evaluation.Processing.Producers.ProducerRecordSetSink.Put(IRecord record) at Microsoft.Ceres.Evaluation.Engine.Aborting.AbortableRecordSetSink.Put(IRecord record) at Microsoft.Ceres.Evaluation.Engine.ErrorHandling.HandleExceptionRecordSetSink.DoWithTryCatch(IRecord record) - -- End of inner exception stack trace --- at Microsoft.Ceres.Evaluation.Engine.ErrorHandling.HandleExceptionRecordSetSink.DoWithTryCatch(IRecord record) at Microsoft.Ceres.InteractionEngine.Component.FlowHandleRegistry.SubmitData(FlowExecutionInfo handle, InputData inputData, Stopwatch timer, String correlationId, Guid tenantId, String query, String flowName, Int32 queryTimeoutMillis) at Microsoft.Ceres.InteractionEngine.Component.FlowHandleRegistry.ExecuteFlow(String flowName, InputData input, Int32 queryTimeoutMillis)

1
<p><b>Bill To Date: </b> _#= billToDate.format("dd/MM/yyyy") =#_ </p>

this property (billToDate) is never mentioned before!

You have missed:

var billToDate = new Date($getItemValue(ctx, "BillToDate"));
  • thanks for noticing that, I changed that, but not difference yet. still the same error on the logs. – Luis Valencia Mar 26 '14 at 12:18
  • 1
    please note some fields are not mandatory, so I guess that is the reason, I believe dueDate.format will throw that error if duedate is empty – Luis Valencia Mar 26 '14 at 12:20
  • I think I am right, but how can I check if the value is an Invalid Date? please see this: screencast.com/t/C7ZhcyPT – Luis Valencia Mar 26 '14 at 12:51
  • First check for null/emtpy (use: $isNull or $isEmptyString) before parsing it as a Date object. If you have multiple cultures to deal with use ctx.CurrentCultureName along with moment.js and then proceed with parsing the respective format. – Aveenav Mar 26 '14 at 23:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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