cancel
Showing results for 
Search instead for 
Did you mean: 

java.lang.IllegalArgumentException: The field 'script' should be set on the TaskListener

paulclinton
Confirmed Champ
Confirmed Champ

Hello,

What I am trying to do is to move a document to a specific folder on approve or reject of a Activiti workflow. I just found a piece of code to do this. The problem is when running the workflow and on Approve of the workflow I'm getting this error- 

java.lang.IllegalArgumentException: The field 'script' should be set on the TaskListener

Please help me out on this. Below is the script that I'm trying to execute-

TestWorkflow.bpmn.xml

<userTask id="alfrescoUsertask1" name="Alfresco User Task" activiti:assignee="${initiator.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><![CDATA[execution.setVariable('wf_reviewOutcome', task.getVariable('wf_reviewOutcome'));
logger.log("Review Outcome got");]]></activiti:string>
</activiti:field>
</activiti:taskListener>
<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string><![CDATA[logger.log("Starting Excute Move Script");
if (task.getVariable('wf_reviewOutcome') == 'Approve'){
var dest= companyhome.childByNamePath("Sites/swsdp/documentLibrary/Approved");
bpm_package.children[0].move(dest);
}
else if (task.getVariable('wf_reviewOutcome') == 'Reject') {
var dest= companyhome.childByNamePath("Sites/swsdp/documentLibrary/Rejected");
bpm_package.children[0].move(dest);
}
]]></activiti:string>
</activiti:field>
</activiti:taskListener>
</extensionElements>
</userTask>

scWorkflowModel.xml

<?xml version="1.0" encoding="UTF-8"?> <!-- Definition of new Model --> <model name="scwf:workflowmodel"     xmlns="http://www.alfresco.org/model/dictionary/1.0">      <!-- Optional meta-data about the model -->     <description>Someco Workflow Model</description>     <author>Jeff Potts</author>     <version>1.0</version>      <!-- Imports are required to allow references to definitions in other models -->     <imports>         <import uri="http://www.alfresco.org/model/dictionary/1.0"             prefix="d" />         <import uri="http://www.alfresco.org/model/bpm/1.0"             prefix="bpm" />     </imports>      <!-- Introduction of new namespaces defined by this model -->     <namespaces>         <namespace uri="http://www.someco.com/model/workflow/1.0"             prefix="scwf" />     </namespaces>      <types>  <type name="scwf:NewTestWorkflow">
<parent>bpm:startTask</parent>
<properties>
<property name="scwf:TestingWorkflow">
<type>d:text</type>
<mandatory>true</mandatory>
<multiple>false</multiple>
</property>
</properties>
<overrides>
<property name="bpm:packageItemActionGroup">
<default>read_package_item_actions</default>
</property>>
</overrides>
</type>  </model>

Log:

2018-09-18 11:56:32,953 DEBUG [repo.jscript.ScriptLogger] [http-bio-8080-exec-9] json form submission for item:
2018-09-18 11:56:32,965 DEBUG [repo.jscript.ScriptLogger] [http-bio-8080-exec-9] kind = task
2018-09-18 11:56:32,965 DEBUG [repo.jscript.ScriptLogger] [http-bio-8080-exec-9] id = activiti$11247
2018-09-18 11:56:33,103 DEBUG [repo.jscript.ScriptLogger] [http-bio-8080-exec-9] Review Outcome got
2018-09-18 11:56:33,107 DEBUG [repo.jscript.ScriptLogger] [http-bio-8080-exec-9] Starting Excute Move Script
2018-09-18 11:56:33,190 DEBUG [repo.jscript.ScriptLogger] [http-bio-8080-exec-9] java.lang.IllegalArgumentException: The field 'script' should be set on the TaskListener
2018-09-18 11:56:33,191 DEBUG [repo.jscript.ScriptLogger] [http-bio-8080-exec-9] Returning 500 status code

1 ACCEPTED ANSWER

paulclinton
Confirmed Champ
Confirmed Champ

Solved this problem. The error was due to a simple error in the script.

View answer in original post

3 REPLIES 3

paulclinton
Confirmed Champ
Confirmed Champ

Solved this problem. The error was due to a simple error in the script.

Can you describe the solution please? 
I couldn't see it

MontesR
Champ in-the-making
Champ in-the-making

Hi!

This error shows beacuse is missing the field script in the .bmpn structure of the service task item, make sure of define the field script as follows 

<serviceTask id="alfrescoScripttask1" name="Archivar evidencia" activiti:class="org.alfresco.repo.workflow.activiti.script.AlfrescoScriptDelegate">
      <extensionElements>
        <activiti:field name="script">
          <activiti:string><![CDATA[//logger.log("example");]]></activiti:string>
        </activiti:field>
      </extensionElements>
    </serviceTask>