Set Tag on folder name (custom folder model)

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Active Member

Set Tag on folder name (custom folder model)

Jump to solution

Hi, i'm on Communty 6.2  for my office installation and i have set-up a main folder "Customers" in which there are N folders, one for each of these. I'm trying to make something like a "customer file" orgarnizzation.

Each customer folder is auto-changed to a custom model (Customer File) for refine the rules applied.

Currently i want to automatically add a tag on these special folders exactly the same as the folder name, and auto apply these tag to any document created/uploaded in the customer folder.

 

Customer (main folder)
|
|_customer A folder (custom model) with tag "customer a"
   |_file.docx (with tag "customer a")
   |_file.jpg (with tag "customer a")
   |_.......

 

Someone can help me in this script? I'm totally new to alfresco... thanks since now!

1 Solution

Accepted Solutions
Highlighted
Active Member

Re: Set Tag on folder name (custom folder model)

Jump to solution

Thank you so much Sanjay for your help!

Using your script and another which i found here
https://hub.alfresco.com/t5/alfresco-content-services-forum/when-using-an-execute-script-rule-how-ca...

 

i was to build two rules, one (your script) which auto generate a tag from the customer folder name (i applyed the rule just for the rist level, ignoring sub folder inside each customer.

After i applyed another rules, on each file which is NOT a folder (so i exclude to tag subfolder) with this script where it apply the tag based on the 5th folder name in the path (which is actually the customer name!):

 

var vCurrentFolder = " "
var vElementCount = 0
var pathArray = document.displayPath.split( '/' );
vElementCount = pathArray.length;
vElementCount = 6;
vCurrentFolder = pathArray[vElementCount];

if(document.isContainer){
    document.addTag(vCurrentFolder);
    document.save();
}else{
    document.addTag(vCurrentFolder);
    document.save();
}

View solution in original post

3 Replies
Highlighted
Senior Member II

Re: Set Tag on folder name (custom folder model)

Jump to solution

Hi,

You can create rule on root folder.That rule is excute script where tag add code is wrriten in js file.

Excute that rule with applied to subfolder.

 

Code : 

if(document.isContainer){
    document.addTag(document.name);
    document.save();
}else{
    document.addTag(document.parent.name);
    document.save();
}
Thanks & Regard,
Sanjay
Highlighted
Active Member

Re: Set Tag on folder name (custom folder model)

Jump to solution

Thank you so much Sanjay for your help!

Using your script and another which i found here
https://hub.alfresco.com/t5/alfresco-content-services-forum/when-using-an-execute-script-rule-how-ca...

 

i was to build two rules, one (your script) which auto generate a tag from the customer folder name (i applyed the rule just for the rist level, ignoring sub folder inside each customer.

After i applyed another rules, on each file which is NOT a folder (so i exclude to tag subfolder) with this script where it apply the tag based on the 5th folder name in the path (which is actually the customer name!):

 

var vCurrentFolder = " "
var vElementCount = 0
var pathArray = document.displayPath.split( '/' );
vElementCount = pathArray.length;
vElementCount = 6;
vCurrentFolder = pathArray[vElementCount];

if(document.isContainer){
    document.addTag(vCurrentFolder);
    document.save();
}else{
    document.addTag(vCurrentFolder);
    document.save();
}

View solution in original post

Highlighted
Community Manager
Community Manager

Re: Set Tag on folder name (custom folder model)

Jump to solution

Hi @TheCondor,

So glad you've been able to resolve your issue with the help of @sanjaybandhniya. Thanks also for reporting how you did it - really helpful to other users. 

Digital Community Manager, Alfresco Software.
Problem solved? Click Accept as Solution!