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!
Solved! Go 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(); }
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(); }
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(); }
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.
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.