cancel
Showing results for 
Search instead for 
Did you mean: 

getting node path from freemarker template

kerem
Champ in-the-making
Champ in-the-making
hi!

In the freemarker template, I want to get the path of noderef by using the following code. 

<#if document?exists>
  <table><tr><th>Node Path</th></tr>
   <#list document.auditTrail as t>
           <tr>
             <#if t.auditMethod="moveNode">
             <#if t.methodArgumentsAsStrings[0]?exists>
                        <#assign x=t.methodArgumentsAsStrings[0]>
                  td>${companyhome.nodeByReference[x].displayPath}</td>
             <#else>
                   <td> </td>
             </#if>
             </#if>              
           </tr>
   </#list>
   </table>
  </#if>

I get the following error:

'Expression companyhome.nodeByReference[x] is undefined on line 12, column 57 in workspace://SpacesStore/ba1b4ef2-a550-11db-b0b5-3b9e2324cece.'

How can i correct it? What is right way to access the path by using noderef in the freemarker template file?
2 REPLIES 2

kevinr
Star Contributor
Star Contributor
I can't see anything obviously wrong with the FreeMarker elements - did you get this to work at all? Where are you calling the freemarker from - i assume it's not part of a workflow script?

Thanks,

Kevin

kerem
Champ in-the-making
Champ in-the-making
I put this template under the Data Dictionary/Presentation Templates.
Then try to run it using the "Preview in Template" button.

companyhome.nodeByReference[noderef] works only if the noderef string is hardcoded. But if a variable is used as it is in the code I sent in my previous post, it gives an error.

As an example:
THIS WORKS:
${companyhome.nodeByReference[workspace://SpacesStore/842895bc-a7d0-11db-b30d-3356f174291a]}

THIS DOES NOT WORK:
<#assign x=t.methodArgumentsAsStrings[0]>
${companyhome.nodeByReference[x].displayPath}


Thanks..