Move an attached to a task document to another node
Greetings to the community, I am using alfresco 6.0.0 Community Edition and I would like to move a document attached to a task to another node on the complete event of the task.
I found from here https://community.alfresco.com/thread/204737-workflow-parallel-group-review-with-move about this "move" function so what I am currently doing is the following:
- Start the process
- Attach an item to the task that I have created using the
/tasks/{taskId}/items (POST)
method of the alfresco REST API.
- Complete the task
The part of my bpmn where I move the file is below:
<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string>
java.lang.System.out.println(bpm_package.children.length);
for (var i = 0; i < bpm_package.children.length; i++){
bpm_package.children.move("b162be92-fb36-44f0-83c1-4432b8261c5a");
}
</activiti:string>
</activiti:field>
</activiti:taskListener>
Where b162be92-fb36-44f0-83c1-4432b8261c5a is the node id of a folder I have created.
Unfortunately, when i complete this task I get the following error:
Node Type: {http://www.alfresco.org/model/content/1.0}content, Node Aspects: [{http://www.alfresco.org/model/content/1.0}auditable, {http://www.alfresco.org/model/system/1.0}referenceable, {http://www.alfresco.org/model/system/1.0}localized]
0.0
2018-11-15 15:43:24,936 ERROR [impl.interceptor.CommandContext] [http-apr-8080-exec-3] Error while closing command context
org.activiti.engine.ActivitiException: Exception while invoking TaskListener: Exception while invoking TaskListener: 10150807 Failed to execute supplied script: 10150806 TypeError: Cannot find function move in object Node Type: {http://www.alfresco.org/model/content/1.0}content, Node Aspects: [{http://www.alfresco.org/model/content/1.0}auditable, {http://www.alfresco.org/model/system/1.0}referenceable, {http://www.alfresco.org/model/system/1.0}localized]. (AlfrescoJS#10)
at org.activiti.engine.impl.persistence.entity.TaskEntity.fireEvent(TaskEntity.java:742)
at org.activiti.engine.impl.persistence.entity.TaskEntity.complete(TaskEntity.java:184)
at org.activiti.engine.impl.cmd.CompleteTaskCmd.execute(CompleteTaskCmd.java:52)
at org.activiti.engine.impl.cmd.CompleteTaskCmd.execute(CompleteTaskCmd.java:24)
at org.activiti.engine.impl.cmd.NeedsActiveTaskCmd.execute(NeedsActiveTaskCmd.java:59)
at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:24)
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:57)
at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:47)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:131)
at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:45)
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31)
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40)
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35)
at org.activiti.engine.impl.TaskServiceImpl.complete(TaskServiceImpl.java:178)
at org.alfresco.rest.workflow.api.impl.TasksImpl.update(TasksImpl.java:821)
at sun.reflect.GeneratedMethodAccessor1556.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
Could anyone shed light on this please? Any help is greatly appreciated :)
java workflow alfresco activiti bpmn
add a comment |
Greetings to the community, I am using alfresco 6.0.0 Community Edition and I would like to move a document attached to a task to another node on the complete event of the task.
I found from here https://community.alfresco.com/thread/204737-workflow-parallel-group-review-with-move about this "move" function so what I am currently doing is the following:
- Start the process
- Attach an item to the task that I have created using the
/tasks/{taskId}/items (POST)
method of the alfresco REST API.
- Complete the task
The part of my bpmn where I move the file is below:
<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string>
java.lang.System.out.println(bpm_package.children.length);
for (var i = 0; i < bpm_package.children.length; i++){
bpm_package.children.move("b162be92-fb36-44f0-83c1-4432b8261c5a");
}
</activiti:string>
</activiti:field>
</activiti:taskListener>
Where b162be92-fb36-44f0-83c1-4432b8261c5a is the node id of a folder I have created.
Unfortunately, when i complete this task I get the following error:
Node Type: {http://www.alfresco.org/model/content/1.0}content, Node Aspects: [{http://www.alfresco.org/model/content/1.0}auditable, {http://www.alfresco.org/model/system/1.0}referenceable, {http://www.alfresco.org/model/system/1.0}localized]
0.0
2018-11-15 15:43:24,936 ERROR [impl.interceptor.CommandContext] [http-apr-8080-exec-3] Error while closing command context
org.activiti.engine.ActivitiException: Exception while invoking TaskListener: Exception while invoking TaskListener: 10150807 Failed to execute supplied script: 10150806 TypeError: Cannot find function move in object Node Type: {http://www.alfresco.org/model/content/1.0}content, Node Aspects: [{http://www.alfresco.org/model/content/1.0}auditable, {http://www.alfresco.org/model/system/1.0}referenceable, {http://www.alfresco.org/model/system/1.0}localized]. (AlfrescoJS#10)
at org.activiti.engine.impl.persistence.entity.TaskEntity.fireEvent(TaskEntity.java:742)
at org.activiti.engine.impl.persistence.entity.TaskEntity.complete(TaskEntity.java:184)
at org.activiti.engine.impl.cmd.CompleteTaskCmd.execute(CompleteTaskCmd.java:52)
at org.activiti.engine.impl.cmd.CompleteTaskCmd.execute(CompleteTaskCmd.java:24)
at org.activiti.engine.impl.cmd.NeedsActiveTaskCmd.execute(NeedsActiveTaskCmd.java:59)
at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:24)
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:57)
at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:47)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:131)
at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:45)
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31)
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40)
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35)
at org.activiti.engine.impl.TaskServiceImpl.complete(TaskServiceImpl.java:178)
at org.alfresco.rest.workflow.api.impl.TasksImpl.update(TasksImpl.java:821)
at sun.reflect.GeneratedMethodAccessor1556.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
Could anyone shed light on this please? Any help is greatly appreciated :)
java workflow alfresco activiti bpmn
add a comment |
Greetings to the community, I am using alfresco 6.0.0 Community Edition and I would like to move a document attached to a task to another node on the complete event of the task.
I found from here https://community.alfresco.com/thread/204737-workflow-parallel-group-review-with-move about this "move" function so what I am currently doing is the following:
- Start the process
- Attach an item to the task that I have created using the
/tasks/{taskId}/items (POST)
method of the alfresco REST API.
- Complete the task
The part of my bpmn where I move the file is below:
<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string>
java.lang.System.out.println(bpm_package.children.length);
for (var i = 0; i < bpm_package.children.length; i++){
bpm_package.children.move("b162be92-fb36-44f0-83c1-4432b8261c5a");
}
</activiti:string>
</activiti:field>
</activiti:taskListener>
Where b162be92-fb36-44f0-83c1-4432b8261c5a is the node id of a folder I have created.
Unfortunately, when i complete this task I get the following error:
Node Type: {http://www.alfresco.org/model/content/1.0}content, Node Aspects: [{http://www.alfresco.org/model/content/1.0}auditable, {http://www.alfresco.org/model/system/1.0}referenceable, {http://www.alfresco.org/model/system/1.0}localized]
0.0
2018-11-15 15:43:24,936 ERROR [impl.interceptor.CommandContext] [http-apr-8080-exec-3] Error while closing command context
org.activiti.engine.ActivitiException: Exception while invoking TaskListener: Exception while invoking TaskListener: 10150807 Failed to execute supplied script: 10150806 TypeError: Cannot find function move in object Node Type: {http://www.alfresco.org/model/content/1.0}content, Node Aspects: [{http://www.alfresco.org/model/content/1.0}auditable, {http://www.alfresco.org/model/system/1.0}referenceable, {http://www.alfresco.org/model/system/1.0}localized]. (AlfrescoJS#10)
at org.activiti.engine.impl.persistence.entity.TaskEntity.fireEvent(TaskEntity.java:742)
at org.activiti.engine.impl.persistence.entity.TaskEntity.complete(TaskEntity.java:184)
at org.activiti.engine.impl.cmd.CompleteTaskCmd.execute(CompleteTaskCmd.java:52)
at org.activiti.engine.impl.cmd.CompleteTaskCmd.execute(CompleteTaskCmd.java:24)
at org.activiti.engine.impl.cmd.NeedsActiveTaskCmd.execute(NeedsActiveTaskCmd.java:59)
at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:24)
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:57)
at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:47)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:131)
at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:45)
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31)
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40)
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35)
at org.activiti.engine.impl.TaskServiceImpl.complete(TaskServiceImpl.java:178)
at org.alfresco.rest.workflow.api.impl.TasksImpl.update(TasksImpl.java:821)
at sun.reflect.GeneratedMethodAccessor1556.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
Could anyone shed light on this please? Any help is greatly appreciated :)
java workflow alfresco activiti bpmn
Greetings to the community, I am using alfresco 6.0.0 Community Edition and I would like to move a document attached to a task to another node on the complete event of the task.
I found from here https://community.alfresco.com/thread/204737-workflow-parallel-group-review-with-move about this "move" function so what I am currently doing is the following:
- Start the process
- Attach an item to the task that I have created using the
/tasks/{taskId}/items (POST)
method of the alfresco REST API.
- Complete the task
The part of my bpmn where I move the file is below:
<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string>
java.lang.System.out.println(bpm_package.children.length);
for (var i = 0; i < bpm_package.children.length; i++){
bpm_package.children.move("b162be92-fb36-44f0-83c1-4432b8261c5a");
}
</activiti:string>
</activiti:field>
</activiti:taskListener>
Where b162be92-fb36-44f0-83c1-4432b8261c5a is the node id of a folder I have created.
Unfortunately, when i complete this task I get the following error:
Node Type: {http://www.alfresco.org/model/content/1.0}content, Node Aspects: [{http://www.alfresco.org/model/content/1.0}auditable, {http://www.alfresco.org/model/system/1.0}referenceable, {http://www.alfresco.org/model/system/1.0}localized]
0.0
2018-11-15 15:43:24,936 ERROR [impl.interceptor.CommandContext] [http-apr-8080-exec-3] Error while closing command context
org.activiti.engine.ActivitiException: Exception while invoking TaskListener: Exception while invoking TaskListener: 10150807 Failed to execute supplied script: 10150806 TypeError: Cannot find function move in object Node Type: {http://www.alfresco.org/model/content/1.0}content, Node Aspects: [{http://www.alfresco.org/model/content/1.0}auditable, {http://www.alfresco.org/model/system/1.0}referenceable, {http://www.alfresco.org/model/system/1.0}localized]. (AlfrescoJS#10)
at org.activiti.engine.impl.persistence.entity.TaskEntity.fireEvent(TaskEntity.java:742)
at org.activiti.engine.impl.persistence.entity.TaskEntity.complete(TaskEntity.java:184)
at org.activiti.engine.impl.cmd.CompleteTaskCmd.execute(CompleteTaskCmd.java:52)
at org.activiti.engine.impl.cmd.CompleteTaskCmd.execute(CompleteTaskCmd.java:24)
at org.activiti.engine.impl.cmd.NeedsActiveTaskCmd.execute(NeedsActiveTaskCmd.java:59)
at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:24)
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:57)
at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:47)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:131)
at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:45)
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31)
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40)
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35)
at org.activiti.engine.impl.TaskServiceImpl.complete(TaskServiceImpl.java:178)
at org.alfresco.rest.workflow.api.impl.TasksImpl.update(TasksImpl.java:821)
at sun.reflect.GeneratedMethodAccessor1556.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
Could anyone shed light on this please? Any help is greatly appreciated :)
java workflow alfresco activiti bpmn
java workflow alfresco activiti bpmn
edited Nov 15 '18 at 14:21
NickAth
asked Nov 15 '18 at 13:28
NickAthNickAth
396314
396314
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Solved
The problem was that the move function expects a node element not the id I passed to it (String).
Fixed code below:
<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string>
for (var i = 0; i < bpm_package.children.length; i++){
var p = bpm_package;
var doc = p.children[i];
var myNode = initiatorhome.childByNamePath("foldertomove/testFolder"); <!-- the names of the nodes under the root directory where the file should be moved to-->
doc.move(myNode);
}
</activiti:string>
</activiti:field>
</activiti:taskListener>
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53320569%2fmove-an-attached-to-a-task-document-to-another-node%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Solved
The problem was that the move function expects a node element not the id I passed to it (String).
Fixed code below:
<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string>
for (var i = 0; i < bpm_package.children.length; i++){
var p = bpm_package;
var doc = p.children[i];
var myNode = initiatorhome.childByNamePath("foldertomove/testFolder"); <!-- the names of the nodes under the root directory where the file should be moved to-->
doc.move(myNode);
}
</activiti:string>
</activiti:field>
</activiti:taskListener>
add a comment |
Solved
The problem was that the move function expects a node element not the id I passed to it (String).
Fixed code below:
<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string>
for (var i = 0; i < bpm_package.children.length; i++){
var p = bpm_package;
var doc = p.children[i];
var myNode = initiatorhome.childByNamePath("foldertomove/testFolder"); <!-- the names of the nodes under the root directory where the file should be moved to-->
doc.move(myNode);
}
</activiti:string>
</activiti:field>
</activiti:taskListener>
add a comment |
Solved
The problem was that the move function expects a node element not the id I passed to it (String).
Fixed code below:
<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string>
for (var i = 0; i < bpm_package.children.length; i++){
var p = bpm_package;
var doc = p.children[i];
var myNode = initiatorhome.childByNamePath("foldertomove/testFolder"); <!-- the names of the nodes under the root directory where the file should be moved to-->
doc.move(myNode);
}
</activiti:string>
</activiti:field>
</activiti:taskListener>
Solved
The problem was that the move function expects a node element not the id I passed to it (String).
Fixed code below:
<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string>
for (var i = 0; i < bpm_package.children.length; i++){
var p = bpm_package;
var doc = p.children[i];
var myNode = initiatorhome.childByNamePath("foldertomove/testFolder"); <!-- the names of the nodes under the root directory where the file should be moved to-->
doc.move(myNode);
}
</activiti:string>
</activiti:field>
</activiti:taskListener>
answered Nov 15 '18 at 15:32
NickAthNickAth
396314
396314
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53320569%2fmove-an-attached-to-a-task-document-to-another-node%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown