cancel
Showing results for 
Search instead for 
Did you mean: 

get tag modification date

jackjm
Champ in-the-making
Champ in-the-making
After being introduced to the awesome Javascript console by Jeff Potts in my earlier post, its much easier to script in Alfresco; Thanks Jeff and Florian.

I was playing around with the tagging API and I just wanted to know if there is a way to get information about when a tag was modified /added to the system via. the javascript api; like the Tag Browser interface.

I haven't found any reference in the API; I am welcome to other ideas or suggestions to get this info. as well.

thanks a lot again for all the help
2 REPLIES 2

afaust
Legendary Innovator
Legendary Innovator
Hello,

You can make use of the fact that tags are actually nothing other than categories, which are exposed via the classification root object in the JavaScript API. Categories are themselves just content nodes with the same basic properties.

As tags are all maintained as top level categories of the cm:taggable aspect, you can retrieve all tags by using:

var tags = classification.getRootCategories("cm:taggable");

Of course this is a lot of data if you only want to check one or two specific tags. You can also retrieve dedicated tags via a Lucene query for the category nodes.

var tagNodes = search.query({query: '+PATH:"/cm:taggable/*" +@cm\:name:"tagName"'});

An alternative way would be to directly access the tag category nodes of a document via the properties map instead of the getTags() function, e.g.:


var tagNodes = document.properties["cm:taggable"];
if (tagNodes != null) {
  for(var idx = 0, max = tagNodes.length; idx < max; idx++){
      logger.getSystem().out("Tag " + tagNodes[idx].name + " modified at " + tagNodes[idx].properties["cm:modified"]);
  }
}

Hope this helps
Axel

jackjm
Champ in-the-making
Champ in-the-making
Yes, it helps a lot. Thank you very much Axel for the detailed answer.

best regards