cancel
Showing results for 
Search instead for 
Did you mean: 

Freemarker sort_by

tfpadilla
Champ in-the-making
Champ in-the-making
Hi everybody,

I have created a custom type of documents and a custom type of folder for containig them.

For showing the documents in a custom view I have created a template.

I need to sort the documents by one of the custom properties but I don't know how to do it.

Reading some posts I have tried with:

<#list space.children?sort_by(["properties","fact:cuenta"]) as child> but it doesn't work.

The error I get is:
Error during processing of the template '?sort_by(…) failed: The "fact:cuenta" subvariable (specified by ?sort_by argument number 2) was not found.'. Please contact your system administrator.

Also i tried with
#list space.children?sort_by(['properties','fact:cuenta']) as child> but I get the same error.

Could anyone help me, please?

Thanks in advance,
Teresa
5 REPLIES 5

xerox
Champ in-the-making
Champ in-the-making
Does every child has your custom property?
If you want to sort  by freemarker, be sure every child have that property.

friendly regards,

Nick

jbarmash
Champ in-the-making
Champ in-the-making
are you 100% certain that each of the children of the space you are looking at has the property "fact:cuenta"?

I just tested with this little script, and it worked fine:


<#list companyhome.children?sort_by(["properties", "cm:name"]) as child>
It works
</#list>

tfpadilla
Champ in-the-making
Champ in-the-making
Yes, all the documents of the space have the property.

In fact, the property is mandatory in the custom type, and this custom type is the only one that this custom space accepts.

For giving more details: the possible subspaces in this space wouldn't have the property but at the moment there aren't subspaces.

<#list space.children?sort_by(["properties", "cm:name"]) as child> also works for me but
<#list space.children?sort_by(["properties", "fact:cuenta"]) doesn't.

Could you, please, try with a property of a custom type in your system?

Thanks a lot for helping me,
Teresa

xerox
Champ in-the-making
Champ in-the-making
It should work. I already used this sort option may times with custom properties.

Did you declare "fact" as prefix for your namespace?
You could try to take the whole name space name.
e.g.: <#list space.children?sort_by(["properties", "aaa.bbb.fact:cuenta"])

Friendly regards,

Nick

tfpadilla
Champ in-the-making
Champ in-the-making
Thanks again for your help.

I've checked everything and it seems to be ok and completely declared ( prefix and so on).

This is very curious:

If I try to use <#list space.children?sort_by(["properties","fact:cuenta"]) as child> in a STANDARD space it WORKS.

But I need some special properties also for the space that contains the documents, so I have a standard space with some aspects added.

These aspects are really simple and they are declared in the same custom model: fact model.

I include them in order to show their simplicity:


<aspect name="fact:factid">
         <title>contador espacio</title>
         <properties>
            <property name="fact:folderid">
               <type>d:int</type>
            </property>
         </properties>
      </aspect>
<aspect name="fact:factacum">
         <title>acumulado</title>
         <properties>
           <property name="fact:acumulado">
               <type>d:float</type>
            </property>
         </properties>
      </aspect>
    
<aspect name="fact:aspclienteid">
         <title>cliente asociado</title>
         <properties>
            <property name="factSmiley Tongueaspclienteid">
               <type>d:text</type>
            </property>
         </properties>
      </aspect> 
<aspect name="fact:aspdocpres">
         <title>documentos presentes</title>
         <properties>
            <property name="factSmiley Tongueaspdocpres">
               <type>d:int</type>
            </property>
         </properties>
      </aspect>      
    
Once I have done it, the exactly same <#list space.children?sort_by(["properties","fact:cuenta"]) as child> DOESN'T WORK in the "aspected" space.

Any idea?,
Thanks again, Nick

Teresa