AnsweredAssumed Answered

Tags not refreshed in doclib (but OK in repository browser)

Question asked by dnallsopp on Aug 24, 2012
Using Alfresco Community 4.0.e, I am creating and tagging a set of folders programmatically (via the JavaScript Console, for the moment). For example:

function create_folder(parent, name, tags){
  var child = parent.childByNamePath(name);
  if(!child){
    child = parent.createFolder(name);
  }
  if(title){
    child.properties["cm:title"] = title;
  }
  if(tags){
    child.clearTags();
    child.addTags(tags);
  }
  child.save();
}

Setting the tags when the folder is created seems to work.

Setting the same tags again on an existing folder causes the tags to disappear from the Document Library tag tree! However, they still appear correctly in the Repository Browser.

Setting different tags on the same folder then repairs the problem, i.e. they appear in the Document Library tag tree.

What's going on?

I can repair the tags by running the following script (from http://blog.alfrescian.com/?p=55 - thanks!) but note that it only works when run as a separate script, after running the script that sets the tags. Appending it to the script that modifies the tags does not work (presumably for transactional reasons?).


function refreshTagScope(folder){
  var refresh = actions.create("refresh-tagscope");
  refresh.execute(folder);
  for each(item in folder.children){
    if (item.isContainer){
      refreshTagScope(item);
    }
  }
}
refreshTagScope(space);

Outcomes