cancel
Showing results for 
Search instead for 
Did you mean: 

How a Callactiviti can access the parent process variables?

purna_cherukuri
Champ in-the-making
Champ in-the-making
Hi,

I am trying to use CallActiviti in my BPMN2.0 process.  But I found it mandatory to pass the input variables to call Activiti as it runs in a child execution. 
Is there a way to pass whole set of parent execution's variables to Callactiviti without mentioning each and every one in bpmn2.0 xml?  Or is there a way to tell Callactiviti to share the variables from it's parent execution without mentioning all the variable names in my process definition?  

We have a large set of variables to pass through, and I am finding it as a maintanence issue if we hard code the variable names in process definition.  Please suggest me on this.
22 REPLIES 22

xseagullx
Champ in-the-making
Champ in-the-making
Hello
May I become a necromancer, and resurrect this thread? 😃

It seems, that problem still exists(at least in version 5.14). Root of it is, as previous persons noticed, that foe ExecutionEntry parent is null, only superProcess is valid.

So, Is it done intentionally, or it's a bug. In that case, what is the simplest workaround?

Regards,
Pavel

jbarrez
Star Contributor
Star Contributor
Hehehe 'a necromancer' 🙂

What exactly in this thread are you referring to: the capability of passing all variables into a called subprocess?

Or the fact you cant reference process variables from a parent in a subprocess cause the parent is null?

xseagullx
Champ in-the-making
Champ in-the-making
It has been said, that "If the variable is NOT defined on the execution itself (in this case, the callActivity execution), the parent is consulted. This goes up the execution-tree until a variable is found…"

But as it is implemented now, it's wrong. We have situations, when parent is null, and only superProcess is reffered up in the hierarchy.

So, I think, if frederikheremans's statement is true, in that case we have a bug, as we can't access superprocess variables from callActivity.

If it's done intensionally, ok, I will look for another way to solve my problem.

In fact, I have smth(String, document identificator) which is global during a process, and I'm looking an easy way to have access to it in every subsequent subprocess.

jbarrez
Star Contributor
Star Contributor
Yes, I also believe it is a bug. It's kinda related to this: https://jira.codehaus.org/browse/ACT-1805
The correct way should indeed be that it searches up the super executions too … but i forsee a lot of side effects there.

jcoveron
Champ in-the-making
Champ in-the-making
Greeting,

I am currently using Activiti 5.17. As I was testing a process which has a "Call Activity" action, I found the same issue as it is reported here. When the process flow enters the process represented by the "Call Activity", I can see that execution parent and parentId are null.

However, if the "Call Activity" is replaced by an embedded subprocess, I can see that the execution variable has correct values. For instance execution.parent equals ExecutionEntity and execution.parentId equals a specific id.

In both case scenarios, the process flow never enters function createSubProcessInstance in org.activiti.engine.impl.pvm.runtime.ExecutionImpl.

I did check the release notes for Activiti 5.18 and I see that this jira ACT-1805 has not been fixed. So, I was wondering if you had plans to fix this bug any time soon, and if in the mean time there is a workaround.

Many thanks in advance.

jbarrez
Star Contributor
Star Contributor
It's an old thread, so my memory is a bit fuzzy here.
But a call activity normally does not inherit variables, hence why it has an input/output mapping.
So variables are not automatically available for call activities (cause they can have different names in the called process, they need a dedicated mapping).

Or am i totally misinterpreting the issue here?

jcoveron
Champ in-the-making
Champ in-the-making
Hi Joram

Thanks for replying. this fast.

According to Frederik in one of his replies: "If the variable is NOT defined on the execution itself (in this case, the callActivity execution), the parent is consulted. This goes up the execution-tree until a variable is found… The reason why the IN and OUT's are there, is because of the BPMN 2.0 spec. So this will only work in the activiti-engine, and is not explicitally part of the spec".

However, since the parent Id is null, there is no way to climb up the execution-tree. But in the case of an embedded subprocess, there is no problem. Based on your answer and what I have found, this is not the case.

So, I was wondering if this is actually a bug which has not been fixed and if there is a workaround.

Many thanks in advance.

Best regards,

jbarrez
Star Contributor
Star Contributor
It's been a year since I said that, people can change ideas based on what they've learned 😉

Currently, I'm actually not sure it should automatically go up the chain of parents, I'm more a fan of explicitly mapping it into the called process now instead of relying on it explicitly.

midiman
Champ in-the-making
Champ in-the-making
Hi,
I know this a bit of an old post - but it's still very relevant.

Is there a way to optionally either auto-import all parent variables to subprocess variables (maybe via the cfg.xml?), or maybe a wildcard in the model, like in=* out=*?

If you can point me to the place in the code where such an inheritance might take place, I'm happy to have a go at putting it in, then publish it for the benefit of others.

I'm using 5.21 currently.

Many thanks,
Peter

warper
Star Contributor
Star Contributor
Hi Peter!
You can create java delegate that gets all process variables and puts them into one map. Put it into input expression and output expression of c all activity.
You can create another java delegate that goes through such map and sets process variables accordingly. Put it after start event of subprocess and after call activity step