cancel
Showing results for 
Search instead for 
Did you mean: 

Booleans on templates

miguel_martins
Champ in-the-making
Champ in-the-making
How can I reference the value of a boolean ?
   <#if document.properties["customSmiley TongueRbols"]?exists>
            It exists
         </#if>
this returns if it exists, but i want to know if its set to true.


Related, how can I display Dates?


Thank you.
6 REPLIES 6

invictus9
Champ in-the-making
Champ in-the-making
Well, ?exists can only be true or false. Hence, it is true when "It exists" is displayed. If you need to assign a value based on the value, you could simply assign it inside the <#if>.

If you want to display a boolean value, I think you would use:

document.properties["customSmiley TongueRbols"]?boolean

As for dates:

document.properties["my:somefield"]?date

or

document.properties["my:somefield"]?datetime

will do

miguel_martins
Champ in-the-making
Champ in-the-making
Bolseiro:  ${document.properties["customSmiley TongueRbols"]?boolean}<BR>

I tried this, but whenever it is used the template view blanks out, breaking, I need to either test the boolean value or to at least show off what value it is placed at, true or false.

The date worked, thank you.

miguel_martins
Champ in-the-making
Champ in-the-making
Sorry for bumping this, but I could really use the help to display the boolean values?

Also, another detail, when displaying dates on templates, if they arent there, it screw up the display. ( as opposed to text, when if the value is not there it just appears as a blank)

mrogers
Star Contributor
Star Contributor
http://wiki.alfresco.com/wiki/Alfresco_REST_Design_Guidelines#true_.2F_false_values

And for dates.   For the bits of the REST API I have worked on we tend to format a string in the correct format and then put that into the model rather than trying to have freemarker format the date.

This may not be the best way, but it works :wink:

mikeh
Star Contributor
Star Contributor
If it's a boolean, just use ?string, which defaults to "true" and "false".

To also handle missing values, using something like:
(document.properties["my:somefield"]!false)?string

The Freemarker documentation is a great resource for this stuff: http://freemarker.org/docs/index.html

Thanks,
Mike

miguel_martins
Champ in-the-making
Champ in-the-making
Thank you for your help, that was very useful, I wasnt aware of the name of the style of code used on templates so it had been harder to search for it.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.