cancel
Showing results for 
Search instead for 
Did you mean: 

Error executing an script in UserTask Workflow

jlabuelo
Champ on-the-rise
Champ on-the-rise
Hi there

We are creating a usertask in a Alfresco 5.0 Share workflow of type "ActivityReviewTask" so the assigned user can approve or reject the task.

We have included a listener so if the user approves the task an Alfresco Script shoule be lauched.


<userTask id="revisarOT" name="Revisar OT" activiti:assignee="externo" activiti:formKey="wf:activitiReviewTask">
      <extensionElements>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[var test = bpm_package;
       var doc = test.children[0];
                   if(task.getVariableLocal('wf_reviewOutcome') == 'Approve') {
        doc.properties["my:estado"]="Aprobada_tecnico";
           doc.save();
                   } else {
        doc.properties["my:estado"]="Rechazada_tecnico";
           doc.save();
                   }]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>


however when we click in Approve task or Reject task we get this error


Exception while invoking TaskListener: The field 'script' should be set on the TaskListener


We dont know exactly where the error is. Would you please give us a hand here??

Thanks a lot in advance

2 REPLIES 2

darkredd
Star Contributor
Star Contributor
Hi,

From a glance, your userTask and its listener looks fine. More information on your process definition please.

vmiorga
Confirmed Champ
Confirmed Champ

I was working with this tuto: https://ecmarchitect.com/alfresco-developer-series-tutorials/workflow/tutorial/tutorial.html

And I get the same error.

This post make me add the variable use b the Alfresco scrip task in the share-config-custom.xml and allowed me to correct the error.

<config evaluator="string-compare" condition="activiti$helloWorldUI">
      <forms>
         <form>
            <field-visibility>
                ....
               <show id="wf:reviewOutcome"></show>
            </field-visibility>

      <appearance>

          ............

           <set id="reviewOutcome" appearance="title" label-id="workflow.set.reviewOutcome"/>

               .............
             <field id="wf:reviewOutcome" set="reviewOutcome"/>
         </appearance>
      </form>