I need a script that moves a file to a folder dynamically. The URL of the folder will be registered in a folder's parent property of the file.
The script should take this parameter from the path to where the file should be moved and move it to it. Can someone give me an example of how to do this?
Thanks
Solved! Go to Solution.
Hi Renato Fritola,
if you running script as the rule then you will get the document object directly..
var parentNode= document.parent;// getting the parent of the docuemnt
var movePath = parentNode.properties["cm:movePath"] //get the path where you want to move from the property
// Path should be some thing like this "sites/test/documentLibrary/testFolder" if not then convert something like this..
var destination =companyhome.childByNamePath(movePath);
document.move(destination);
Plz look in to this bellow links for all the methods and root object you will get in to javascript..
1)Root objects | Alfresco Documentation
2)ScriptNode API | Alfresco Documentation
3)JavaScript API Cookbook
Thanks
Shyam Ghodasra
Hi Renato Fritola,
if you running script as the rule then you will get the document object directly..
var parentNode= document.parent;// getting the parent of the docuemnt
var movePath = parentNode.properties["cm:movePath"] //get the path where you want to move from the property
// Path should be some thing like this "sites/test/documentLibrary/testFolder" if not then convert something like this..
var destination =companyhome.childByNamePath(movePath);
document.move(destination);
Plz look in to this bellow links for all the methods and root object you will get in to javascript..
1)Root objects | Alfresco Documentation
2)ScriptNode API | Alfresco Documentation
3)JavaScript API Cookbook
Thanks
Shyam Ghodasra
Worked perfectly!
Thank you.
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.