cancel
Showing results for 
Search instead for 
Did you mean: 

Error on my simple new content type

andrea_girardi
Champ in-the-making
Champ in-the-making
Hi all,

I created this new content type:


<aspect name="kc:HealthNewsItem">
   <title>Knowledge Base Article</title>
   <properties>
      <property name="kc:news_id">
         <title>Old News identifier</title>
         <type>d:int</type>
      </property>
      <property name="kc:status_type">
         <title>News status</title>
         <type>d:text</type>
         <constraints>
            <constraint ref="kc:status_constraint"/>
         </constraints>
      </property>   
   </properties>
</aspect>

And, with a JS I'm trying to create a new object on Repository:


var title = args.title;
var body = args.body;
var news_id = args.id;

var article = companyhome..createNode("article", "cm:content");
article.addAspect("kc:HealthNewsItem");
article.properties["kc:news_id"] = news_id;
article.properties["cm:name"] = title;
article.properties["kc:status_type"] = "Archived";
article.content = args.body;
article.save();

model.article = article;

It's working fine because I found the object on repository but, when I cannot access to properties news_id and status_type if I try this:

<html>
   <head>
      <title>Sample ${article.name}</title>
   </head>
   <body>
      <p>Title : ${article.name} = ${article.id} = ${article.news_id}</p>
      <p>Body : ${article.content}</p>
   </body>
</html>

This is the error message I can see on alfresco log: freemarker.core.InvalidReferenceException: Expression article.news_id is undefined on line 6, column 64 in mySample/add.get.html.ftl.

How can I fix that? How can I see the new properties I added on my model with Alfresco?

thanks for your time, I'm really freaking out…..  :shock:
Andrea
1 REPLY 1

openpj
Elite Collaborator
Elite Collaborator
You have to get custom properties using the QName as the key of a single property value, in the following way:

<html>
   <head>
      <title>Sample ${article.name}</title>
   </head>
   <body>
      <p>Title : ${article.name} = ${article.id} = ${article.properties["kc:news_id"]}</p>
      <p>Body : ${article.content}</p>
   </body>
</html>
Hope this helps.
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.