AnsweredAssumed Answered

callActivity not setting the start user in second execution

Question asked by iblanco on Jun 13, 2016
Latest reply on Jul 1, 2016 by jbarrez
I'm using Activiti 5.19 embeded in Alfresco.
I'm doing some test to check if calling activities dynamically could solve one of our use cases.

So I defined a workflow that simply takes a process name from a config variable and calls that activity. The activity itself executes a little script task and then starts an Alfresco User Task. When the task is completed the activity ends and it goes back to the parent process. Then the parent process checks the config again and executes the next activity and so on…

The first time the callActivity is used everything works fine but the second time the callActivity starts the subprocess without setting an owner (start_user_id in table ACT_HI_PROCINST is null in the DB ) for child process.

This is the process XML (without the graphical part for brevity):


<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://activiti.org/bpmn">
  <process id="testProcessChooseProcess" name="Proceso selector de trámites" isExecutable="true">
    <startEvent id="chooserStartEvent" name="Process chooser start event" activiti:formKey="twf:submitChooseProcess"></startEvent>
    <exclusiveGateway id="exclusivegateway1" name="Exclusive Gateway"></exclusiveGateway>
    <callActivity id="callNextActivity" name="Call next activity" calledElement="${nextActivity}">
      <extensionElements>
        <activiti:in source="bpm_sendEMailNotifications" target="bpm_sendEMailNotifications"></activiti:in>
        <activiti:in source="bpm_workflowDueDate" target="bpm_workflowDueDate"></activiti:in>
        <activiti:in source="bpm_assignee" target="bpm_assignee"></activiti:in>
        <activiti:in source="bpm_workflowPriority" target="bpm_workflowPriority"></activiti:in>
        <activiti:in source="bpm_workflowDescription" target="bpm_workflowDescription"></activiti:in>
        <activiti:in source="initiator" target="initiator"></activiti:in>
      </extensionElements>
    </callActivity>
    <sequenceFlow id="nextProcessSequence" name="Call next process" sourceRef="exclusivegateway1" targetRef="callNextActivity">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${nextActivity != null}]]></conditionExpression>
    </sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="noMoreProcessesSequence" name="No more processes" sourceRef="exclusivegateway1" targetRef="finalTaskAssigment">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${nextActivity == null}]]></conditionExpression>
    </sequenceFlow>
    <serviceTask id="alfrescoScripttask1" name="Get next activiti" activiti:class="org.alfresco.repo.workflow.activiti.script.AlfrescoScriptDelegate">
      <extensionElements>
        <activiti:field name="script">
          <activiti:string><![CDATA[logger.log("Parsing twf_processConfig v17…");
var nextActivity = 'dummyUserProcess';
execution.setVariable('nextActivity', nextActivity);
logger.log("Next activity will be: " + nextActivity);]></activiti:string>
        </activiti:field>
      </extensionElements>
    </serviceTask>
    <sequenceFlow id="flow1" sourceRef="chooserStartEvent" targetRef="alfrescoScripttask1"></sequenceFlow>
    <sequenceFlow id="flow2" sourceRef="alfrescoScripttask1" targetRef="exclusivegateway1"></sequenceFlow>
    <userTask id="finalTaskAssigment" name="Final user task" activiti:assignee="${initiator.properties.userName}" activiti:formKey="wf:adhocTask"></userTask>
    <sequenceFlow id="flow4" sourceRef="finalTaskAssigment" targetRef="endevent1"></sequenceFlow>
    <sequenceFlow id="flow6" sourceRef="callNextActivity" targetRef="alfrescoScripttask1"></sequenceFlow>
  </process>


Outcomes