Are these same?

I have selectedAddresses as output variable in a Service Task http-connector in Camunda modeller

Which is the correct way to access this variable in Java class ?

String x = execution.getVariable("selectedAddresses");

Or

String x = (String) runtimeService.getVariable(processId, "selectedAddresses");

Yes, if processId is the same as execution.getId(). Maybe if processId is the same as execution.getProcessInstanceId(). Read up on variable scopes here: https://docs.camunda.org/manual/7.8/user-guide/process-engine/variables/

1 Like