AnsweredAssumed Answered

Document's properties via WebScript

Question asked by k.warcaba on Nov 14, 2008
Latest reply on Nov 17, 2008 by k.warcaba
Hi all,

I have a strange problem. I wrote a simple WebScript which should retrieve documents and its properties for defined category. Here is my code:

var categoryNode = search.luceneSearch("PATH:\"" + args.path + "\"");
if (categoryNode == undefined)
   status.code = 404;
   status.message = "Kategoria o referencji: " + args['path'] + " nie zostala znaleziona.";
   status.redirect = true;
   // perform category search
   model.categoryFiles = search.luceneSearch("PATH:\"" + args.path + "//member\"");

This code works quite good. As an args.path I use qnamePath of the Category Node which I retrieve in other WebScript. The code is based on one of the WebScripts in the wiki page WebScripts Examples.

Response Template:
    "feed": {
  <#assign x = 0>         
<#list categoryFiles as child>    
<#if child.isContainer == false>
  <#assign x = x+1>   
        "entry${x}": {
            "param_title": "${}",
             <#list as t>
                <#– If the property exists –>
                   <#– If it is a date, format it accordingly–>
                "param_${t}" : "${[t]?date}",
                   <#– If it is a boolean, format it accordingly–>
                "param_${t}" : "${[t]?string("yes", "no")}",
                   <#– Otherwise treat it as a string –>
                "param_${t}" : "${[t]}",
              <#assign y = 0>              
              <#list child.aspects as asp>    
                  "aspect${y}" : "${asp}",
                  <#assign y = y+1>                   
             "param_href": "${absurl(url.serviceContext)}/api/node/content/${child.nodeRef.storeRef.protocol}/${child.nodeRef.storeRef.identifier}/${}/${}",
             "param_icon" : "${url.context}${child.icon32}",
             "param_nodeRef" : "${child.nodeRef}",
             "param_nodeType" : "${child.type}",
             "param_size" : "${child.size}"
        "updated": "${xmldate(date)}"

And here id the problem. When I try to create JSON response I receive an error. It is connected with above Response Template. Everything works fine when I delete lines:
                   <#– Otherwise treat it as a string –>
                "param_${t}" : "${[t]}",
but then there are no String properties in the response. I would like to mention that I use the same RESPONSE TEMPLATE for my other WebScripts and everything is fine.

Can anyone help me with this issue?

Thanks in Advance,
Kamil Warcaba