Zeebe : How can I get process variables using process Instance ID

Hi,

Im trying to fetch all variables of given process instance outside worker method.

Requirement is:
External system calls our rest endpoint(non-zeebe) and our system trigger the message event(publish message) using zeebe client and during this call, I want to pass updated existing process variables.
Say I want to update status of employee verification object/json to “success”.

Hence trying to access it using process instance id. I tried to find method using zeebeClient object but no luck till now.

Kindly provide your inputs.

Thank you in advance

Hey @camundabpmlearner! :wave:
My recommendation is to only change variables from within the process. If you start doing this from the outside you can cause some serious damage to running processes.

When doing changes of process variables from within the process I can recommend using event based subprocesses which are being triggered via messages. You could also pass variables along.

1 Like

Hi @Hafflgav
My problem is, how can we access variable which comes in later stage?
Here in subscription correlation I mapped variable which will have value in later stage but as soon as I start process, I get error saying expected value but found NULL, this is pointing to variable processInstanceId which I create in first worker.

Thank you in advance.

Hey @camundabpmlearner,
I would need some more of your code / process to help you out here.

But to get this right:
You do not want to initialise values using the non-interrupting event-based process, right? It is just about overriding already existing values. (This differentiation would be quite important to make this work)

Hi @Hafflgav
I kept non-interrupting because I dont want to move out tokens from main process and shift to here, instead generate new token to update.

Example:

Note:
I want to update order object with additional values in later stage

@camundabpmlearner, that’s correct!
But the variables you want to update already exist in the “main process”.

The processInstanceId is created during the start of the process. In case the process does not exist yet you cannot update any variables.
You would also need to start the process with an object that contains the values you want to override.

Hi @Hafflgav ,
Let me rephrase it,

My correlation id in non-interrupting message event is, processId + “#” + orderId and
Both ProcessId & orderId generated in Task A worker.

Yes, Order object coming as input here but I’m generating my own Id(UUID) & mapping instanceId to process variable inside Task A’s Worker.

Since I map these variables in correlation key, it throws exception saying, expected string found null.

Ah, I see. I got an alternative idea:
What do you think about using a subprocess in addition?

1 Like

Hi @Hafflgav
This can be one of the solution. I will give a try.

1 Like

Looking forward to hear from you whether this workaround is going to work! :slight_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.