Javascript to move file into folder

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2016 02:42 PM
Hi All,
I have recently deployed alfresco(5.1.0 community edition) to manage our internal documents and it works great.
I would like to implement a hot folder where once a file is uploaded to the folder it is moved to a folder with the same title as the file.
What I mean is if I upload a file with a title KD/IT/SOP/1 it should be moved to folder with the title KD/IT/SOP
I have been researching and it seems doing a rule that calls javascript would be my best option. However, I'm pretty new to javascript and wouldn't know where to start. Any pointers would by highly appreciated.
I have recently deployed alfresco(5.1.0 community edition) to manage our internal documents and it works great.
I would like to implement a hot folder where once a file is uploaded to the folder it is moved to a folder with the same title as the file.
What I mean is if I upload a file with a title KD/IT/SOP/1 it should be moved to folder with the title KD/IT/SOP
I have been researching and it seems doing a rule that calls javascript would be my best option. However, I'm pretty new to javascript and wouldn't know where to start. Any pointers would by highly appreciated.
Labels:
- Labels:
-
Archive
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2016 03:57 PM
<a href="http://docs.alfresco.com/5.1/references/API-JS-move.html">Here</a> is the doc on the "move" method.
In your folder rule you'll automatically get a variable named document. So if you can use other calls to get a handle to the folder node you want to move it to, you can call that move function.
Looks like you'll also want to create a new folder to place that document in. So you'll want to call createFolder on the parent to create the new folder before you call move on the document.
Jeff
In your folder rule you'll automatically get a variable named document. So if you can use other calls to get a handle to the folder node you want to move it to, you can call that move function.
Looks like you'll also want to create a new folder to place that document in. So you'll want to call createFolder on the parent to create the new folder before you call move on the document.
Jeff

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2016 04:54 AM
var strDestFolder ="sites/KD/IT/SOP/";
var objDestFolder = companyhome.childByNamePath(strDestFolder);
document.move(objDestFolder);
if the destination folder is not the same you may generate a path variable from eg the node (document) name. won´t work if the destination folder does not exist or you don´t have correct permissions (needing delete in the source path).
kr
Josef
var objDestFolder = companyhome.childByNamePath(strDestFolder);
document.move(objDestFolder);
if the destination folder is not the same you may generate a path variable from eg the node (document) name. won´t work if the destination folder does not exist or you don´t have correct permissions (needing delete in the source path).
kr
Josef

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2016 05:21 AM
var strDestFolder ="sites/KD/IT/SOP/";
var objDestFolder = companyhome.childByNamePath(strDestFolder);
document.move(objDestFolder);
if the destination folder is not the same you may generate a path variable from eg the node (document) name. won´t work if the destination folder does not exist or you don´t have correct permissions (needing delete in the source path).
kr
Josef
var objDestFolder = companyhome.childByNamePath(strDestFolder);
document.move(objDestFolder);
if the destination folder is not the same you may generate a path variable from eg the node (document) name. won´t work if the destination folder does not exist or you don´t have correct permissions (needing delete in the source path).
kr
Josef
