Alfresco Share – refresh tagscope cache

Alfresco uses a concept called tagscope caching to support performant tagging services in Alfresco Share. Each folder representing a site or a site container (doclib, wiki…)  has a d:content property cm:tagScopeCache thats acts as a tag cache. More detailed this property is a txt-file that contains a list of tags & their quantity, e.g.:

test|2
test2|1

Sometimes these tagScopeCache are out-of-sync (at least in Alfresco 3.1), so I wrote a simple Javascript snippet to refresh this caches:

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);

Steps to use this script:

  1. Upload js to data dictionary / Scripts
  2. navigate in JSF client to site or site container where you want to refresh your tagScopeCache
  3. open details page of folder
  4. Run Action -> Execute Script & choose the uploaded script.