cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass a variable from the called workflow to the calling workflow?

alper
Champ in-the-making
Champ in-the-making
I do execution.setVariable("A","B") while in the parent workflow.
Then paren workflow passes the variable A to the child workflow, and I do execution.setVariable("A","C") in the child workflow.
Upon returning to the parent workflow I do execution.getVariable("A") and get "B"!
So changes done in the child workflow were not saved.
What am I doing wrong? How to correctly pass the variable from the child workflow to the upper level?
Thank you.
7 REPLIES 7

pkonyves
Champ in-the-making
Champ in-the-making
Try the passing variables chapter: http://activiti.org/userguide/#bpmnCallActivity
Or if that does not work, you can try retrieving the DelegateExecution#parentId(), and use runtimeservice to set the variable back to the parent execution.

alper
Champ in-the-making
Champ in-the-making
Yes, I read this chapter and did according to that, but it doesn't work for some reason. Is that a bug?
I tried to define a brand-new variable, but it doesn't exist in the execution of the parent workflow when I test:

<code>
      <extensionElements>
        <activiti:in source="level" target="tasksList"></activiti:in>
        <activiti:in source="first" target="first"></activiti:in>
        <activitiSmiley Surprisedut source="first" target="first1"></activitiSmiley Surprisedut>
      </extensionElements>
</code>

jbarrez
Star Contributor
Star Contributor
'Doesn't work' is hard to debug. The only way to prove it's a bug is through a unit test that demonstrates the problem.

kalpanaab
Champ in-the-making
Champ in-the-making
Hi,
am new to activiti
I have one main process in that am using callactiviti.
<callActivity id="callactivity1" name="Call activity" calledElement="activitiAdhoc">
      <extensionElements>
        <activiti:in sourceExpression="${myNewActivity.getExpression()}" target="result"></activiti:in>
      </extensionElements>
    </callActivity>
am setting some value in the variable named result.
But I don't know how to retrieve that value in calledElement "activitiAdhoc" .
Please suggest me how I can do that.
Thanks,
Kalpana

kalpanaab
Champ in-the-making
Champ in-the-making
Hi,
am new to activiti
I have one main process in that am using callactiviti.
<callActivity id="callactivity1" name="Call activity" calledElement="activitiAdhoc">
      <extensionElements>
        <activiti:in sourceExpression="${myNewActivity.getExpression()}" target="result"></activiti:in>
      </extensionElements>
    </callActivity>
am setting some value in the variable named result.
But I don't know how to retrieve that value calledElement "activitiAdhoc" .
Please suggest me how I can do that.
Thanks,
Kalpana

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Kalpana,

see org.activiti.examples.bpmn.callactivity.CallActivityTest in the activiti source.

Regards
Martin

kalpanaab
Champ in-the-making
Champ in-the-making
Hi Martin,
Already I tried that code. myExecutionDelegate is my bean where I tried that logic to get the variable.

and got the below exception
Exception in thread "main" org.activiti.engine.ActivitiException: Error while evaluating expression: ${myExecutionDelegate.getVariable()}
at org.activiti.engine.impl.el.JuelExpression.getValue(JuelExpression.java:57)
at org.activiti.engine.impl.bpmn.behavior.ServiceTaskExpressionActivityBehavior.execute(ServiceTaskExpressionActivityBehavior.java:50)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:60)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:633)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:628)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerStart.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerStart.java:52)
at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:56)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:633)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:628)
at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:49)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:633)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:628)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionCreateScope.execute(AtomicOperationTransitionCreateScope.java:49)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:633)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:628)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerTake.execute(AtomicOperationTransitionNotifyListenerTake.java:80)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:633)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:628)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionDestroyScope.execute(AtomicOperationTransitionDestroyScope.java:116)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:633)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:628)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerEnd.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerEnd.java:35)
at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:56)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:633)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:628)
at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:49)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:633)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:628)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.take(ExecutionEntity.java:452)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.take(ExecutionEntity.java:430)
at org.activiti.engine.impl.bpmn.behavior.BpmnActivityBehavior.performOutgoingBehavior(BpmnActivityBehavior.java:140)
at org.activiti.engine.impl.bpmn.behavior.BpmnActivityBehavior.performDefaultOutgoingBehavior(BpmnActivityBehavior.java:66)
at org.activiti.engine.impl.bpmn.behavior.FlowNodeActivityBehavior.leave(FlowNodeActivityBehavior.java:44)
at org.activiti.engine.impl.bpmn.behavior.FlowNodeActivityBehavior.execute(FlowNodeActivityBehavior.java:36)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:60)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:633)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:628)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationProcessStartInitial.eventNotificationsCompleted(AtomicOperationProcessStartInitial.java:45)
at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:56)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:633)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:628)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationProcessStart.eventNotificationsCompleted(AtomicOperationProcessStart.java:64)
at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:56)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:633)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:628)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.start(ExecutionEntity.java:380)
at org.activiti.engine.impl.bpmn.behavior.CallActivityBehavior.execute(CallActivityBehavior.java:112)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:60)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)

Thanks,
KAlpana B