cancel
Showing results for 
Search instead for 
Did you mean: 

JavaScript to move files

ado
Champ in-the-making
Champ in-the-making
Hi

I am trying to write a script that would get a file (jpeg) from a certain store/directory and copy/delete or move it into another store/directory within the same site in alfresco.

I have absolutely no clue as to do this and I'm very new to JavaScript. This coding is only part of a larger extention that seems to be working fine. The file that needs to be obtained from the first directory's filename is passed as a parameter in the POST URL. I have read up on DOM objects but its unclear to me how I would apply this to get the document first and then assign it to the document object. Can this be done? Is there some other means of getting a document and moving or copying it?

Any help would be greatly appreciated.

Thanks in advance

ADO
1 REPLY 1

rajanigupta
Champ in-the-making
Champ in-the-making
hii


assuming that both spaces depends on the same root space, you should use something like this in your process definition:

<task-node name="approved">
<task name="wf:approvedParallelTask" swimlane="initiator" />
<transition to="end">
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<runas>admin</runas>
<script>
<variable name="bpm_package" access="read" />
<expression>
var origin = bpm_package.children[0].parent;
var root = origin.parent;
var destination = root.childByNamePath("approved");
if (destination == null)
{
destination = origin.createFolder("approved");
}
                                                      
for (var i=0; i &lt; bpm_package.children.length; i++)
{
     bpm_package.children.move(destination);
}  
</expression>
</script>
</action>
</transition>
</task-node>