Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

201
Views
Alfresco Add Category based on Tag

I would like to create a script to use as a folder rule to add a category based on the tag.

This script successfully adds the category to the file.

var catNodeRef = search.findNode("workspace://SpacesStore/XXXXXXXXXXXXXXXXXXXX");
var categories= document.properties["cm:categories"];

if (categories == null ) {
categories = new Array (); }
     
categories.push(catNodeRef);
document.properties["cm:categories"] = categories;
document.save();
};

However, when I add the findTaggedNodes, the script fails.

var taggedNodes =  findTaggedNodes("workspace://SpacesStore/XXXXXXXXXtagnumber");
var taggable= document.properties["cm:taggable"];
if (taggedNodes == "workspace://SpacesStore/XXXXXXXXXtagnumber" )

{
var catNodeRef = search.findNode("workspace://SpacesStore/88b392ce-a50c-4079-a8cb-8a18faafc154");
var categories= document.properties["cm:categories"];

if (categories == null ) {
categories = new Array (); }
     
categories.push(catNodeRef);
document.properties["cm:categories"] = categories;
document.save();
};

I have also tried

var taggable= document.properties.hastag = "aaf observatory";

if(var taggable)
{
var catNodeRef = search.findNode("workspace://SpacesStore/88b392ce-a50c-4079-a8cb-8a18faafc154");
var categories= document.properties["cm:categories"];

if (categories == null ) {
categories = new Array (); }
     
categories.push(catNodeRef);
document.properties["cm:categories"] = categories;
document.save();
};

Any help would be appreciated. (NOTE: I am not a developer)

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

findTaggedNodes don't work in javascript, you can use it in Java with TaggingService , in JavaScript you need to use search.findNode(TAG_NODE_REF) to get the node of the tag with the nodeRef.

var taggable = document.properties["cm:taggable"]; return a collection of tags, you cannot compare it with string value. you need a loop to compare if the collection contain same node et use node1.equals(node2)

You find script here :

var nodeTag = search.findNode('workspace://SpacesStore/XXXXXXXXXtagnumber');
//Get Tags of document 
var documentTags = document.properties["cm:taggable"];

for each(var tag in documentTags) {

    if(tag.equals(nodeTag)) {

        //Tag is found in document, add the category with function 
        addCAtegory(document, "workspace://SpacesStore/REF_ID_CATEGORY");
    }
}

function addCAtegory(node, categoryNodeRef) {
    
    var catNodeRef = search.findNode(categoryNodeRef);
    var categories= node.properties["cm:categories"];

    if (categories == null ) {
        categories = new Array (); 
    }
     
    categories.push(catNodeRef);
    node.properties["cm:categories"] = categories;
    node.save();
}

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!