简体   繁体   English

Alfresco:编写工作流程脚本以将文档复制到同一文件夹中,并继续使用新文档进行工作流程

[英]Alfresco: Write workflow script to copy document in same folder and continue workflow with new document

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: 我没有太多的Java经验,但是我正在努力实现以下目标:

<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 马库斯

Basically the argument in copy function is the object of parent node and not a path to parent node. 基本上,复制函数中的参数是父节点的对象,而不是父节点的路径。

So the below code will do the work. 因此,以下代码将完成工作。

bpm_package.children[0].copy(bpm_package.children[0].parent);

You do not need to call save or any other function after that.Basically this are javascript api of alfresco. 之后,您无需调用save或任何其他函数。基本上,这是alfresco的javascript API。 You can take a look on below link for more details. 您可以在下面的链接上查看更多详细信息。

http://docs.alfresco.com/4.1/references/API-JS-Scripting-API.html http://docs.alfresco.com/4.1/references/API-JS-Scripting-API.html

Thanks to Krutik for answering the first part of the answer. 感谢Krutik回答了答案的第一部分。 I'm adding the solution to changing the document in the workflow. 我正在添加解决方案以更改工作流程中的文档。 This is done by adding and removing documents from the bpm_package property. 这是通过在bpm_package属性中添加和删除文档来完成的。 The whole script is as below: 整个脚本如下:

var newdoc = bpm_package.children[0].copy(bpm_package.children[0].parent);
bpm_package.removeNode(bpm_package.children[0]);
bpm_package.addNode(newdoc);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM