Generically Pass Parameters to every subprocess

I have a hashmap that tracks request information, that I want to generically pass to every subprocess I invoke in BPMN. Is there any easy way to accomplish this other than modifying the input parameters inside the modeler of every bpmn file?

Is the subprocess the same bpmn?

You could have the sub-process execute a delegate/script that accesses the “parent process” and grabs your hashmap variable.

It is across separate bpmns, I just want to propagate the larger transaction context for logging without manual work on each new bpmn created.

Hi @Ramlaen
you maybe can make use of a process engine plugin.

As an example we created once a process engine plugin that automatically passes the business key to the sub process that is called by a call activity. Per default you would have to check the checkbox on business key on every call activity. You can find the example here: https://github.com/camunda-consulting/code/tree/master/snippets/bpmn-parse-listener-on-call-activity
Maybe this helps you to build your custom plugin or you reuse it to pass the business key and then based on the business key you do a variable query.

Best
Felix

Yes this looks very promising, now I just have to figure out how to access and add to the input variables. The documentation is not so straight forward.

I had some more time to play with this, while this seems fine in the debugger. It does not appear to get deployed to the bpmn itself. I can see the new attribute added with source/target just like the others are. I am not sure where I am going wrong.

@Override
public void parseCallActivity(Element callActivityElement, ScopeImpl scope, ActivityImpl activity) {	
Element extensionElement = callActivityElement.element("extensionElements");
    	AttributesImpl attributes = new AttributesImpl();
    	attributes.addAttribute("", "", "source", "source", "request-id");
    	attributes.addAttribute("", "", "target", "target", "request-id");
    	Element traceInput = new Element("http://camunda.org/schema/1.0/bpmn", "in", null, attributes, null);
    	extensionElement.add(traceInput);

I was able to figure it out I was just adding the variables wrong.

CallableElementActivityBehavior callableElementActivityBehavior = (CallableElementActivityBehavior) activity.getActivityBehavior();
	AttributesImpl attributes = new AttributesImpl();
	attributes.addAttribute("", "", "source", "source", "gOpenTracerContext");
	attributes.addAttribute("", "", "target", "target", "gOpenTracerContext");
	 
	Element traceInput = new Element("http://camunda.org/schema/1.0/bpmn", "in", null, attributes, null);
	CallableElementParameter parameter = parseCallableElementProvider(traceInput);
	callableElementActivityBehavior.getCallableElement().addInput(parameter);

Hi @Ramlaen
What is parseCallableElementProvider