Is the process instance id available as variable in the process instance?

I have a simple flow, with as first step a REST API call to log some process instance attributes; I want to maintain an (external) log that a process has started.

Is the process instance id available as a variable in the process instance? I could not find this in the documentation or examples, and trying things like processInstanceId or execution.processInstanceId or zeebe.process_instance_key are not working.

On the other hand, I think (or hope) that such an attribute – just like: process instance start timestamp, process model id, process model version – is available from the process instance itself.

Hi @jschulenklopper,

no, right now, the processInstanceKey is not available as a process variable automatically.

If you write your own worker, you can use job.getProcessInstanceKey() to access the processInstanceKey and save it to your variable.

Hope this helps, Ingo

Thanks for the custom worker solution, and that the job.getProcessInstanceKey() is available there.

It’s unfortunate the variables are not available in the instance directly. I can think of cases where it’d be convenient that process instance variables (start time, process instance id, process definition id, process definition version, …) are available in the process instance, for example to log some process data from the process towards an external system. Then the logged data can be correlated to the specific process and process execution.

The other solution that I can think of now is to include a logging service as a first process step, let it generate and return some data (including a random identifier that’ll act as a process instance key) that is made available as a variable in the process.

1 Like

If you’re working in C8, would an Exporter not work?

This way, you’re not loading the logging into the process itself, but into the overall execution environment.

(I think I probably missed something…)

1 Like

I think this is related to FEEL expressions for Camunda attributes / entities. · Issue #10987 · camunda/zeebe · GitHub

Maybe you can add your thoughts here so it can be considered in planning :slight_smile:

Greets
Chris