Hi all,after a task rejection I need to remove one (it's the only one) package item programmatically. After that, I will choose my new file and continue with my workflow. The problem is NOT with the new file I'm adding, but with the old one which is not removed correctly.In the user task I tried:
<activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string>
logger.log("TRYING TO REMOVE OLD (REJECTED) PACKAGE ITEM…");
execution.setVariable('bpm_package', null);
</activiti:string>
</activiti:field>
</activiti:taskListener>
<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string>
logger.log("TRYING TO SET NEW PACKAGE ITEM…");
execution.setVariable('bpm_package', task.getVariable('bpm_package'));
</activiti:string>
</activiti:field>
</activiti:taskListener>
This does not work as it still tries to point to a node which does not exist anymore. So I tried:
<activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string>
logger.log("TRYING TO REMOVE OLD (REJECTED) PACKAGE ITEM…");
execution.removeVariable('bpm_package');
</activiti:string>
</activiti:field>
</activiti:taskListener>
<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string>
logger.log("TRYING TO SET NEW PACKAGE ITEM…");
execution.setVariable('bpm_package', task.getVariable('bpm_package'));
</activiti:string>
</activiti:field>
</activiti:taskListener>
More or less same issue. And:
<activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string>
logger.log("TRYING TO REMOVE OLD (REJECTED) PACKAGE ITEM…");
var input_package = execution.getVariable('bpm_package');
input_package.remove();
execution.setVariable('bpm_package', input_package);
</activiti:string>
</activiti:field>
</activiti:taskListener>
<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string>
logger.log("TRYING TO SET NEW PACKAGE ITEM…");
execution.setVariable('bpm_package', task.getVariable('bpm_package'));
</activiti:string>
</activiti:field>
</activiti:taskListener>
Which still does not work. I have the impression I'm missing something out there. Any idea?