Forcing variables to CallActivity

Hi guys!
I’ve several processes that have 1 or more Call Activities.
All our processes need some “system variables” grouped in a map(i.e.: environment, track id, client_name, etc.).
I would like to build a piece of code to add via code in a ParseListener that adds this map (systemVariables) to the called process in the Call Activity as is shown in the following screenshot.
call_activity

I know I must implement the parseCallActivity but I didn’t find any documentation that shows how to add that variable.

Do you have some additional documentation/code snippet/recommendation to give me?

Thank you in advanced!
Diego

Well, I think I found a solution.
Since I need to add the map mentioned in the previous post, I have implemented a Parser Listener base on AbstractBpmnParseListener with the following Override:

  @Override
  public void parseCallActivity(
      Element callActivityElement, ScopeImpl scope, ActivityImpl activity) {
    CallableElement element =
        ((CallActivityBehavior) activity.getActivityBehavior()).getCallableElement();
    CallableElementParameter elementParameter = new CallableElementParameter();

    elementParameter.setSourceValueProvider(
        new ConstantValueProvider("systemVariables"));
    elementParameter.setTarget("systemVariables");
    elementParameter.setAllVariables(false);
    elementParameter.setReadLocal(false);

    element.addInput(elementParameter);

    super.parseCallActivity(callActivityElement, scope, activity);
  }

This solution is working fine for each Call Activity I have in Camunda.
It was very hard to find a solution because I was not able to find any kind of documentation or code snipped related to this need.

If you think you have a better solution, I will appreciate your comments, guys!

Cheers!
Diego

Why do the variables need to be passed? Why can’t the called process access them?

Good question!
First, an introduction :slight_smile:
Those variables are part of the tracking info for each request we have in our system.
Some of those variables are HTTP headers. So, We build a filter to inject headers as variables.
Those variables are taken automatically by a Java delegate that makes HTTP requests.
Due to the fact it is mandatory to have that tracking info, we think it is a good idea to make it automatically.
And now, answering your question, processes invoked using call activity tasks doesn’t have visibility of parent’s variables. So you need to specify which variable you want to pass to the called process.
Regards,
Diego

Aha! Now the situation is clearer now. The values are not static but rather per request / process instance.

Can’t you then attach a listener to the call activity? The listener would set the system vars as a local variable. As the varable input mapping, youd’d then choose “all” and “local”.

1 Like

Sure! And that was the first approach.
But there are three main reasons I wanted it in this way:

  1. We have a lot of BPMs and I don’t want to modify each one.
  2. We are about 400 developers in our team, and it’s easier to have some features in an automatic way than left the devs to add a listener :wink:
  3. Last, but not least, it’s a tech requirement. And I like to keep the BPMs as clean as possible. I mean, I like to have only business logic into their