cancel
Showing results for 
Search instead for 
Did you mean: 

Add automatic comments at document

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

I need to create automatic comments on each document added to a folder in Alfresco share. I decided to set up a rule that acts on the folder concerned.

In the XML file that identifies the custom template that I created I added that the type must have a mandatory aspect of type fm: discussable.

That way if I navigate in the browser of knots and I position it on the document that I put into the folder that acts on the rule, I see that as children the property fm: I gather that discussion is derived from the addition Aspect declared mandatory in the custom template .

Now I wonder why if I do I print to the log of tomcat document.aspects me this line is printed only this?

{http://www.alfresco.org/model/content/1.0}auditable,{http://www.alfresco.org/model/system/1.0}refere...

What's wrong?

Thanks at all
6 REPLIES 6

need
Champ in-the-making
Champ in-the-making
Help me please

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

i write this script for create comment:

document.addAspect("fm:discussable");

var c = document.childAssocs["fm:discussion"];

for each(var n in c){
 
  //if(n.typeShort == "fm:forum"){
  n.createNode("Comments"+Math.random(),"fm:topic");
  var child = n.children;
 
  for each(var e in child){
    if (e.typeShort == "fm:topic"){
   
      logger.log("SONO NELLA IF");
      var props = new Array(1);
      props["cm:content"] = "";
      e.createNode("Comments"+Math.random(),"fm:post",props);
   
    }
  }
}

Now in node browser i see the comment after insert the document in folder. Now when i try click on cm:content value in browser node i see this error in the browser:


404 Description:    Requested resource is not available.

Message:   04070011 Unable to locate content for node ref workspace://SpacesStore/2e1c7117-459b-48f8-8498-f0f0dacb832b (property: {http://www.alfresco.org/model/content/1.0}content)

What's wrong?

Thanks a lot.

need
Champ in-the-making
Champ in-the-making
Now i modified the script:

document.addAspect("fm:discussable");

var c = document.childAssocs["fm:discussion"];

for each(var n in c){
 
  //if(n.typeShort == "fm:forum"){
  n.createNode("Comments"+Math.random(),"fm:topic");
  var child = n.children;
 
  for each(var e in child){
    if (e.typeShort == "fm:topic"){
   
      logger.log("SONO NELL'IF");
      var props = new Array(1);
      props["cm:content"] = document.properties.content;
      e.createNode("Comments"+Math.random(),"fm:post",props);
      //e.save();
    }
  }
}

now i see the content, but on share i don't see the "fake" comment on document. WHY?????

need
Champ in-the-making
Champ in-the-making
Ok i've resolved!!!

dnallsopp
Champ in-the-making
Champ in-the-making
This seems to work via the JavaScript console (rather laborious - would love a shorter way…).


var node = search.findNode("workspace://SpacesStore/c66d546f-6c90-4583-8e76-30763848dd8a") ;  
logger.log(node);

if(!node.hasAspect("fm:discussable")) { node.addAspect("fm:discussable"); }
if(!node.hasAspect("fm:commentsRollup")) { node.addAspect("fm:commentsRollup"); }

var forums = node.childAssocs["fm:discussion"];
var forum;
if(forums.length === 0) {
  forum = node.createNode(node.properties.name+" discussion", "fm:forum", "fm:discussion");
}
else {
  forum = forums[0];
}
logger.log(forum);

var topics = forum.childAssocs["cm:contains"];
var topic;
if(topics.length === 0) {
  topic = forum.createNode("Comments", "fm:topic", [], "cm:contains", "cm:Comments");
}
else {
  topic = topics[0];
}
logger.log(topic);

var now = new Date();
var name = "comment-"+now.getTime();
var mypost = topic.createNode(name, "fm:post", [], "cm:contains", name);

mypost.content = "<p>Hello World!<p>";

sharifu
Confirmed Champ
Confirmed Champ
Is there a similar way to retrieve revision comments of a document?