Hi all,I've made a workflow with review/approve transition steps. This workflow is called via JS, which is run via a rule:
function newBatch(assignee, doc){
var workflowPackage = workflow.createPackage();
workflowPackage.addNode(doc);
var workflowDef = workflow.getDefinitionByName("activiti$StartReviewBatch");
var parameters = new Object();
parameters["bpm:assignee"] = assignee;
parameters["bpm:workflowDescription"] = "Please review " + doc.name;
var workflowPath = workflowDef.startWorkflow(workflowPackage, parameters);
}
What I would like to do is have the workflow move the document attached to the appropriate Approved or Rejected folders. Here is a snippet of my current definition: <userTask id="usertask1" name="Review" activiti:assignee="${bpm_assignee.properties.userName}" activiti:formKey="wf:activitiReviewTask">
<extensionElements>
<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string>execution.setVariable('wf_reviewOutcome', task.getVariable('wf_reviewOutcome'));</activiti:string>
</activiti:field>
</activiti:taskListener>
<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string>if (task.getVariable('wf_reviewOutcome') == 'Approve'){
var dest= companyhome.childByNamePath("Sites/jstest/documentLibrary/Approved");
bpm_package.children[0].move(dest);
} else if (task.getVariable('wf_reviewOutcome') == 'Reject') {
var dest= companyhome.childByNamePath("Sites/jstest/documentLibrary/Rejected");
bpm_package.children[0].move(dest);</activiti:string>
</activiti:field>
</activiti:taskListener>
</extensionElements>
</userTask>
<endEvent id="endevent1" name="End"></endEvent>
I'm unsure if the bpm_package.children[0] is the correct way to reference the attached document. Gives a 'Failure' error box when clicking transition buttons.Can anyone point me in the right direction? I've read the API and searched for hours on this.Cheers