cancel
Showing results for 
Search instead for 
Did you mean: 

Document description in a mail template

carlos_gonzalez
Champ in-the-making
Champ in-the-making
Hi,
I'm trying send by email the document description property. If i use document.properties["description"] in a Presentation Template works ok but not in email templates. any idea?

thanks
13 REPLIES 13

carlos_gonzalez
Champ in-the-making
Champ in-the-making
Maybe this can be a clue.

I have this ftl template:

<b>Name:</b> ${document.name}<br>
<b><#if document.properties.description?exists>${document.properties.description}</#if><br>

<b>Ref:</b> ${document.nodeRef}<br>
<b>Type:</b> ${document.type}<br>
<b>Content URL:</b> <a href="/alfresco${document.url}">/alfresco${document.url}</a><br>
<b>Locked:</b> <#if document.isLocked>Yes<#else>No</#if><br>
<b>Aspects:</b>
<table>
<#list document.aspects as aspect>
    <tr><td>${aspect}</td></tr>
</#list>
</table>


<table>
<#– Get a list of all the property names for the document –>
<#assign props = document.properties?keys>
<#list props as t>
    <#– If the property exists –>
    <#if document.properties[t]?exists>
       <#– If it is a date, format it accordingly–>
       <#if document.properties[t]?is_date>
       <tr><td>${t} = ${document.properties[t]?date}</td></tr>
      
       <#– If it is a boolean, format it accordingly–>
       <#elseif document.properties[t]?is_boolean>
       <tr><td>${t} = ${document.properties[t]?string("yes", "no")}</td></tr>
      
       <#– Otherwise treat it as a string –>
       <#else>
       <tr><td>${t} = ${document.properties[t]}</td></tr>
       </#if>
    </#if>
</#list>
</table>

and i get this result:

<b>Name:</b> BSO3222.txt<br>
<b><br>

<b>Ref:</b> workspace://SpacesStore/33464553-2023-4e5f-ade9-0578ba487e2d<br>
<b>Type:</b> {http://www.alfresco.org/model/content/1.0}content<br>
<b>Content URL:</b> <a href="/alfresco/d/d/workspace/SpacesStore/33464553-2023-4e5f-ade9-0578ba487e2d/BSO3222.txt">/alfresco/d/d/workspace/SpacesStore/33464553-2023-4e5f-ade9-0578ba487e2d/BSO3222.txt</a><br>
<b>Locked:</b> No<br>
<b>Aspects:</b>
<table>
    <tr><td>{http://www.alfresco.org/model/content/1.0}auditable</td></tr>
    <tr><td>{http://www.alfresco.org/model/system/1.0}referenceable</td></tr>
    <tr><td>{http://www.alfresco.org/model/content/1.0}titled</td></tr>
    <tr><td>{http://www.alfresco.org/model/content/1.0}author</td></tr>
    <tr><td>{http://www.alfresco.org/model/application/1.0}inlineeditable</td></tr>
</table>


<table>
       <tr><td>{http://www.alfresco.org/model/content/1.0}name = BSO3222.txt</td></tr>
       <tr><td>{http://www.alfresco.org/model/content/1.0}modified = 29-jul-2009</td></tr>
      
       <tr><td>{http://www.alfresco.org/model/content/1.0}creator = admin</td></tr>
       <tr><td>{http://www.alfresco.org/model/system/1.0}store-protocol = workspace</td></tr>
       <tr><td>{http://www.alfresco.org/model/system/1.0}store-identifier = SpacesStore</td></tr>
       <tr><td>{http://www.alfresco.org/model/content/1.0}created = 29-jul-2009</td></tr>
      
       <tr><td>{http://www.alfresco.org/model/application/1.0}editInline = yes</td></tr>
      
       <tr><td>{http://www.alfresco.org/model/system/1.0}node-dbid = 2.671</td></tr>
       <tr><td>{http://www.alfresco.org/model/content/1.0}content = org.alfresco.repo.template.BaseContentNode$TemplateContentData@6824edb3</td></tr>
       <tr><td>{http://www.alfresco.org/model/content/1.0}title = BSO.txt</td></tr>
       <tr><td>{http://www.alfresco.org/model/system/1.0}node-uuid = 33464553-2023-4e5f-ade9-0578ba487e2d</td></tr>
       <tr><td>{http://www.alfresco.org/model/content/1.0}modifier = admin</td></tr>
</table>

You can see that the description property doesn´t appear there.

carlos_gonzalez
Champ in-the-making
Champ in-the-making
This is the log message

freemarker.template.TemplateException: Expected extended hash. document

thestorm
Champ in-the-making
Champ in-the-making
ahhhhh why didnt i see that before reference it like this:

document.properties["description"]

had the same problem already but forgot it.

Properties are stored in an array and u can access them with the name of the propertie as string.

regards Sebastian

kbonnet
Champ in-the-making
Champ in-the-making
Another hint:

In your template you use ${document.properties.description}, besides the tip of The Storm above (but mind the typo), you might also need to use ${document.properties["cm:description"]!}, with the exclamation mark. Freemarker is very picky about variables not having a value. With the exclamation mark you can state an alternative value, like ${document.properties["cm:description"]!"No description available"}. If you dont append the last string, it gets replaced with nothing.

Hope this helps too.

Koen