05-11-2017 08:48 AM
Hi all
For one of my workflows, I want to be able to select a document in my start task. Then, I would like to execute a script to make a copy of this document in the same folder, and continue the workflow with the new document (if this is possible). I don't have much java experience but I'm trying to achieve something along the lines of:
<script>
var path = bpm_package.children[0].displayPath;
var newdoc = bpm_package.children[0].copy(path);
newdoc.save();
bpm_package = newdoc;</script>
Any help would be greatly appreciated!
Marcus
05-12-2017 03:00 AM
I have found a solution to this. First we copy the document using the .parent property of bpm_package and assign it to a new variable. Then we can remove the original document from bpm_package and add the new one in it's place, as with the following code:
var newdoc = bpm_package.children[0].copy(bpm_package.children[0].parent);
bpm_package.removeNode(bpm_package.children[0]);
bpm_package.addNode(newdoc);
05-11-2017 09:38 AM
05-12-2017 01:51 AM
Hi Greg
This is for a workflow within Alfresco (using the activiti engine). I may have got confused about the two categories, but I thought ECM would be mainly for content modelling/structuring and BPM would be for everything workflow related?
05-12-2017 03:00 AM
I have found a solution to this. First we copy the document using the .parent property of bpm_package and assign it to a new variable. Then we can remove the original document from bpm_package and add the new one in it's place, as with the following code:
var newdoc = bpm_package.children[0].copy(bpm_package.children[0].parent);
bpm_package.removeNode(bpm_package.children[0]);
bpm_package.addNode(newdoc);
Explore our Alfresco products with the links below. Use labels to filter content by product module.