AnsweredAssumed Answered

Activiti & Liferay: cannot change status for Documents&Media

Question asked by olgaels on Oct 22, 2012
Latest reply on Oct 22, 2012 by jbarrez
Hi!

I designed a workflow for approving new Document (file). It is just a simple workflow: 1 user task and 1 script task changing status of document:


  <process id="SimpleProcess" name="SimpleProcess">
    <startEvent id="startevent1" name="Start"></startEvent>
    <endEvent id="endevent1" name="End"></endEvent>
    <scriptTask id="scripttask1" name="Script Task" scriptFormat="LiferayJavaScript">
      <script><![CDATA[Packages.com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil.updateStatus(Packages.com.liferay.portal.kernel.workflow.WorkflowConstants.toStatus("approved"), workflowContext);]]></script>
    </scriptTask>
    <userTask id="usertask1" name="User Task" activiti:candidateGroups="#{liferayGroups.getGroups(execution, &quot;Administrator&quot;)}"></userTask>
    <sequenceFlow id="flow1" name="" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow>
    <sequenceFlow id="flow2" name="" sourceRef="scripttask1" targetRef="endevent1"></sequenceFlow>
    <sequenceFlow id="flow3" name="" sourceRef="usertask1" targetRef="scripttask1"></sequenceFlow>
  </process>

After the workflow ends, the document gets status "approved". The problem is, that we have business requirement to change the status at the very beginning of workflow, before user task. I just change usertask and scripttask:


  <process id="SimpleProcess" name="SimpleProcess">
    <startEvent id="startevent1" name="Start"></startEvent>
    <endEvent id="endevent1" name="End"></endEvent>
    <scriptTask id="scripttask1" name="Script Task" scriptFormat="LiferayJavaScript">
      <script><![CDATA[
      Packages.com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil.updateStatus(Packages.com.liferay.portal.kernel.workflow.WorkflowConstants.toStatus("approved"), workflowContext);
      ]]></script>
    </scriptTask>
    <userTask id="usertask1" name="User Task" activiti:candidateGroups="#{liferayGroups.getGroups(execution, &quot;Administrator&quot;)}"></userTask>
    <sequenceFlow id="flow1" name="" sourceRef="startevent1" targetRef="scripttask1"></sequenceFlow>
    <sequenceFlow id="flow2" name="" sourceRef="scripttask1" targetRef="usertask1"></sequenceFlow>
    <sequenceFlow id="flow3" name="" sourceRef="usertask1" targetRef="endevent1"></sequenceFlow>
  </process>

and status doesn't change, the document stays "pending". Why does it happen? Could the "workflowContext" be empty before first usertask? Is it possible to run only scripttask in workflow?

Thanks!

P.S. there are no exceptions in server log files, in both cases I see, that updateStatus method has been called:


20:05:05,289 INFO  [http-bio-6080-exec-188][LiferayScriptEngine:39] Perform Script (javascript): Packages.com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil.updateStatus(Packages.com.liferay.portal.kernel.workflow.WorkflowConstants.toStatus("approved"), workflowContext);

Outcomes