AnsweredAssumed Answered

Freemarker scripts... how to detect missing properties?

Question asked by theorbix on Jun 22, 2008
Latest reply on Jan 9, 2009 by satishvarmadandu
I'm writing a custom Web Script that returns the result of a query in JSON format.

This is the Freemarker script I use to generate the JSON output:

<#assign x = 0>
<#list search.results as row>         
<#assign x = x+ 1>
<#if x != search.itemsPerPage>


The problem is that sometimes the documents resulting from the search do not contain the description property (I don't know why…. this should be a default property of all documents contained in Alfresco), and this causes an exception in the execution of the Freemarker script:

freemarker.core.InvalidReferenceException - Expression is undefined on line 15, column 34 in org/alfresco/repository/search/keywordsearch.get.json.ftl. 

How can I avoid this error? Is there a way, in a Freemarker script, to check if a note property exist?