AnsweredAssumed Answered

How to retrieve properties description via Javascript

Question asked by kitelabs on Nov 5, 2012
Latest reply on Nov 6, 2012 by kitelabs
Hi guys,
I need help to retrieve properties descriptions as specified in my customModel.xml

In my model I have something like that:

……….

        <property name="fa:customer">
           <title>Customer Name</title>
           <type>d:text</type>
           <mandatory>true</mandatory>
           <index enabled="true">
                  <atomic>false</atomic>
                  <stored>false</stored>
                  <tokenised>true</tokenised>
           </index>
        </property>
……..
Now I need to retrieve the string "Customer Name" between  <title></title> tag.
Using a simple webscript, I am able to get the full list of properties for a desired document in this way:

documentprops.get.desc.xml
<webscript>
<shortname>Document Properties</shortname>
<description>It provides document’s property</description>
<url>/sample/documentprops?nodeRef={nodeRef}</url>
<format default="json">argument</format>
<authentication>user</authentication>
<transaction>none</transaction>
</webscript>

documentprops.get.js
 var query = "@sys\\:node-uuid:" + "\"" + args.nodeRef + "\"" + " AND TYPE:\"cm:content\"";
var results = search.luceneSearch(query);
model.document = results[0];

and the .ftl is:

documentprops.get.json.ftl
{
"properties" : [
<#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>
       "${t}": "${document.properties[t]?string("yyyy-MM-dd")}"
       <#– If it is a boolean, format it accordingly–>
       <#elseif document.properties[t]?is_boolean>
       "${t}": "${document.properties[t]?string("yes", "no")}"
       <#– Otherwise treat it as a string –>
       <#else>
       "${t}": "${document.properties[t]}"
       </#if>
    </#if> }
    <#if t_has_next>,</#if>
</#list>
]
}
In this way, I can get the full list pointing to the url http://localhost:8080/alfresco/service/sample/documentprops?nodeRef=beb21716-f5f0-421a-a366-2f0cf85a85b6
but I need to get, for each property, the label as assigned into model file ("Customer Name" in this case).

I can get, for example:
…..
"{http://www.kitelabs.it/model/content/1.0}customer": "DELL MAROCCO"
……

So the property name is "{http://www.kitelabs.it/model/content/1.0}customer" and the property value is "DELL MAROCCO"

I would like to know if there is a way to obtain the property description (or property label or displayName I don't know what is the right name) corresponding to "Customer Name".

Thanks in Advance

Outcomes