Pyzeebe newSetVariablesCommand

i need to set variables to job element Instance
any way to do it in pyzeebe(python)?

Hey @CMX,
not sure if I understand you correctly - what do you mean by “job element instance”?

If you want to pass a variable from a service task back to the process instance you can so like this for instance:

@worker.task(task_type="do-something", exception_handler=on_error)
async def do_something(inputValue: str) -> dict: 
    return {"output": f"{inputValue} + XYZ !"}

Let me know if this was what you are looking for!

i mean like this
from java

Command to set and/or update the variables of a given flow element (e.g. process instance, task, etc.)

elementInstanceKey – the key of the element instance to set/update the variables for
a builder for the command

I have never seen that before besides in some older JavaDocs. Usually you would use something like this in Java:

	@ZeebeWorker(type = "generate-uuid")
	public void generateCertificateOfRecovery(final JobClient client, final ActivatedJob job, @ZeebeVariable String person_uuid) {
		UUID _uuid = UUID.randomUUID();

				.variables("{\"uuid\": \"" +uuid + "\"}")
				.exceptionally( throwable -> { throw new RuntimeException("Could not complete job " + job, throwable); });

So just to recap:
You want to complete a job with a python worker and return some values to the process instance right?

i want to do something like this

add vars to the context
then throw error
then use this vars as output in boundary event

consts.ErrorMessageVarName: reason,
consts.ErrorCodeVarName: errorCode,


Hey @CMX - sorry for the delay!
I have been quite busy on our company’s annual retreat. :slight_smile:

Since you want to do this in python I do recommend using the pyzeebe client. The author has some documentation up and running right here. I would suggest taking a look at it. If you use this there should be no thing as a “ElementInstanceKey”.

Perhaps with