Search code examples
alfrescoactiviti

Not able to access 'task' object in workflow service task


I am able to access "task" object in workflow user tasks.

<userTask id="usertask1" name="Manager Approval" activiti:candidateGroups="GROUP_ALFRESCO_MANAGERS" activiti:formKey="tcdr:managerForDeleteApproval">
        <extensionElements>
            <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
              <activiti:field name="script">
                  <activiti:string>
                  logger.log(task.getName());
                  </activiti:string>
              </activiti:field>
            </activiti:taskListener>
        </extensionElements>    
    </userTask>

I am not able to access "task" object in workflow service task, it's giving error of "task not defined".

<serviceTask id="scripttask2" name="Submit" activiti:class="org.alfresco.repo.workflow.activiti.script.AlfrescoScriptDelegate">
      <extensionElements>
        <activiti:field name="script">
          <activiti:string><![CDATA[
          logger.log(task.getName());
          ]]></activiti:string>
        </activiti:field>
      </extensionElements>
    </serviceTask>

Solution

  • Try to use execution instead task, I had the same problem with startTask, but I'm not sure if it will work with seviceTask