AnsweredAssumed Answered

Association properties in json.ftl

Question asked by nikhilaraballi on Feb 27, 2014
Latest reply on Feb 27, 2014 by nikhilaraballi
How to get properties of association object using json.ftl?


I have a type abc:appDate.  It has a property abc:dateTime an association to self ie.,

    <association name="abc:nextAppDate">
    <title>Next App Date</title>
    <source>
       <mandatory>false</mandatory>
       <many>false</many>
    </source>
    <target>
       <class>abc:appDate</class>
       <mandatory>false</mandatory>
       <many>true</many>
    </target>
    </association>

I was trying to get properties of association as below, but getting "Error during processing of the template 'Expression result.assocs[\"abc:nextAppDate\"] is undefined"

    <#macro dateFormat date>${date?string("dd MMM yyyy")}</#macro>
        <#escape x as jsonUtils.encodeJSONString(x)>
        {
           "nodeRef": "${result.nodeRef}",   
           "date": "<@dateFormat result.properties["abc:dateTime"] />",
            "nextDate": [
          <#list result.assocs["abc:nextAppDate"] as childKey>
          {
          "date": "<@dateFormat childKey.properties["abc:dateTime"] />"            
          }
          <#if child_has_next>,</#if>
           </#list>
          ]
        }
        </#escape>

Outcomes