Define Transient Variables in BPMN?

When configuring a custom Service-Task i prefer to use camunda’s Input / Output Parameters. I realized, that in most cases i don’t really need the Input-Parameters to be persisted. Is it possible to declare (within my BPMN) that certain Input-Parameters shall be transient ones?

I know that i can use Field-Injections instead, but than i end up spreading the required Servie-Task-Inputs as Field-Injections (if no persistence is needed) and Input-Parameters (if persistence is required).

I don’t think this is possible. input and out parameters will always create a regular variable. There isn’t any way i know of that you could make it transient.

@sreiser you can implement the following as Start Listeners or Task Listeners:

Listener: Script: javascript

var Variables = Java.type('org.camunda.bpm.engine.variable.Variables')
var myStringVar = Variables.stringValue("myValue", true)
execution.setVariableLocal("theTransientVariableName", myStringVar)

Should be able to one line it with something like:

execution.setVariableLocal('theVariableName', Java.type('org.camunda.bpm.engine.variable.Variables').stringValue("myValue", true))

see Variables (Camunda BPM Javadocs 7.14.6-ee) for other methods available other than stringValue(...)

It would prob be a good feature request for Camunda to expose the Variables class in the EL Resolver so expressions can access the org.camunda.bpm.engine.variable.Variables static methods

1 Like