03-26-2020 06:05 AM
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!
04-07-2020 09:26 AM
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(); }
04-07-2020 07:34 AM
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(); }
04-07-2020 09:26 AM
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(); }
04-08-2020 11:10 AM
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.
Explore our Alfresco products with the links below. Use labels to filter content by product module.