cancel
Showing results for 
Search instead for 
Did you mean: 

How to assign input CallActivity subprocess

arief
Champ in-the-making
Champ in-the-making
Hi,

I'm new to this BPM. May I know how to assign variable 'workOrderApproved' upon callActivity to subprocess 'inventoryRelease' ?


        <sequenceFlow id='flow4' sourceRef="workOrderApprovedDecision" targetRef="createInventoryRelease">
            <conditionExpression xsi:type="tFormalExpression">${workOrderApproved}</conditionExpression>
        </sequenceFlow>
       
        <callActivity id="createInventoryRelease" name="Inventory release" calledElement="inventoryRelease">

Thanks
4 REPLIES 4

frederikherema1
Star Contributor
Star Contributor
Hi,

First solution is to add a service-task in between the sequenceflow and the call-activity:

<serviceTask id="setVarServiceTask">
    activiti:expression="#{value}"
    activiti:resultVariableName="workOrderApproved" />

If this is to intrusive (adding an element to set a simple variable) you can use an event-listener (which is available in activiti.5.0.rc1, released this monday). The example below will set the variable 'workOrderApproved' when the transition 'flow4' is taken.

<sequenceFlow id='flow4' sourceRef="workOrderApprovedDecision" targetRef="createInventoryRelease">
    <conditionExpression xsi:type="tFormalExpression">${workOrderApproved}</conditionExpression>
    <extensionElements>
        <activiti:listener expression="${execution.setVariable('workOrderApproved', value)}" />
    </extensionElements>
</sequenceFlow>
       
<callActivity id="createInventoryRelease" name="Inventory release" calledElement="inventoryRelease">

For more info about the possibilities of expressions and eventllisteners, check out the userguide. This has some good info about this subject.

arief
Champ in-the-making
Champ in-the-making
hi, thanks for the reply.

if I change your code in ExecutionImpl.java

public PvmProcessInstance createSubProcessInstance(PvmProcessDefinition processDefinition) {
    ExecutionImpl subProcessInstance = newExecution();
   
    // manage bidirectional super-subprocess relation

    subProcessInstance.setParent(this);//arief add this

    subProcessInstance.setSuperExecution(this);
    this.setSubProcessInstance(subProcessInstance);
   
    // Initialize the new execution
    subProcessInstance.setProcessDefinition((ProcessDefinitionImpl) processDefinition);
    subProcessInstance.setProcessInstance(subProcessInstance);

    return subProcessInstance;
  }

by setting the subProcess's parent,
The subprocess will automatically get the variable from it's parent (if it can't find the variable in the process).
And  I don't need to change or add something to the BPMN work flow. :mrgreen: 

Perhaps, my additional line of code above would solve other issue regarding 'execution.getParent() always return null' (i saw it on other thread).

in addition,

I commented out line 65 of AtomicOperationActivityEnd.java

        //parentScopeExecution.setActivity(parentActivity);
This will solve nullPointer exception when subprocess end.

I don't know if changes I made would break the activiti, but so far it works for me. I'm happy  :mrgreen:

frederikherema1
Star Contributor
Star Contributor
I misunderstood your question. The example above is for a single process, not for passing of variables to subproces, my bad Smiley Wink

tombaeyens
Champ in-the-making
Champ in-the-making
1) good point, we don't have data mapping capabilities yet in the process definition to specify transfer of data between super process and sub process : http://jira.codehaus.org/browse/ACT-354

2) if the setParent() is all that it takes to enable variable lookup, that would be cool.  in theory it could work like that.  but i would be surprised if there no side effect to setting the parent for that purpose.  (e.g. i believe the isProcessInstance() is implemented as parent!=null)

would be nice if that feature makes it in.  might take a couple of months for us to get to that feature.  if you want it, file a jira feature request and vote for it.