When using a javascript as the execute script rule on a sub folder how can I determine the name of the subfolder that I am in when the rule executes?
Our subfolders are in the name of one the files custom metadata. so when moving or copying files I would like to change this piece of metadata to the name of the folder in which the file is being placed.
So what I require is to capture the subfolder name and use this text to populate my metadata field.
Amy help would be greatly appreciated.
Thanks
Solved! Go to Solution.
You can access the parent folder of the rule triggering document with
document.parent
this is an alfreswco scripting node and so document.parent.name would be the name of the directory.
Another possibility is to use document.displayPath, that represents the whole path to the document as string. Splitting it by '/' would give you all pathelements...
regards,
Martin
You can access the parent folder of the rule triggering document with
document.parent
this is an alfreswco scripting node and so document.parent.name would be the name of the directory.
Another possibility is to use document.displayPath, that represents the whole path to the document as string. Splitting it by '/' would give you all pathelements...
regards,
Martin
The answer above was perfect and using the "displayPath" option enabled me to capture the last 3 folders of the path so I could determine which metadata to use. for anyone else who maybe in the same situation please find a version of my code below and I hope it can help someone in the future.
//------------------------------------------------------------
var vCurrentFolder = " "
var vElementCount = 0
var pathArray = document.displayPath.split( '/' ); // Split Path into Array by backslash
vElementCount = pathArray.length; // How many Elements in the Array
vElementCount = vElementCount - 1; // Number of Last Element
vCurrentFolder = pathArray[vElementCount]; // Load Variable with Current Folder Name
document.properties["kb:mtopic"] = vCurrentFolder ; // Load Metadata item with Current Folder name
document.save(); // Save Document Details
//-------------------------------------------------------------
Obviously by adjusting the vElementCount variable you can look as far back up the path as is possible.
Again Thank you Martin for taking the time to help me resolve this issue.
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.