0

In Alfresco users can use rules to move files. How do I programmatically move a file from one folder to another?

Do you have an example?

I am using Alfresco 7.0 Share/Community version

1 Answers1

1

Using Script :

var backupFolder = space.childByNamePath('testfolder');
if (backupFolder == null)
{
   backupFolder = space.createFolder('testfolder');
}

document.move(backupFolder );

Ref : https://hub.alfresco.com/t5/alfresco-content-services-hub/javascript-api-cookbook/ba-p/293260

https://docs.alfresco.com/content-services/6.1/develop/reference/repo-root-objects-ref/

Sanjay
  • 2,481
  • 1
  • 13
  • 28
  • Thank you. I saw this 2019 solution earlier and couldn't get it to work, so I reposted the question. Based on the example above, I tried to move the document to "testfolder". However, the file didn't move. Ideas? Kim var parentNode= document.parent; var movePath = parentNode.properties["cm:movePath"]; var destination = sites/test/documentLibrary/testfolder(movePath); document.move(destination); – Kim Stewart Apr 04 '22 at 22:19
  • Check edited answer – Sanjay Apr 05 '22 at 05:14
  • Thank you Sanjay. The script works in my system. – Kim Stewart Apr 05 '22 at 17:09