External tasks run with local variables

Hello all!

I have two service tasks in my process definition with external implementation and the same topic (“sendMessage”). I know that an external task is invoked via /external-task/fetchAndLock, but I do not see in documentation a way to pass in parameters that would only be valid for the scope of the execution of the particular task. Is it even possible?

Thank you.

Hi @andreypanin

So is your use case, that you have local variables that have already been created on camunda’s side that you’d like to be given to your external task through the fetch and lock call?
Or are you interested in just passing local variables after the task is complete?

Hello @Niall,

The first part. I am using REST API, to begin with. I know that one can supply global variables to POST /process-definition/{id}/start. They should be valid for the whole duration of the process instance. I also know that I can manipulate them via separate API calls (for example, PUT /process-instance/{id}/variables/{varName}).

There are two activities, service tasks, with external implementation and the same topic. I want the first one to take varA as input parameter and another to take varB. I do not want to define varA and varB in the global scope. Is there a way to supply them to /external-task/fetchAndLock? After the worker has finished, I do not need neither varA nor varB in the global scope.

Setting these values as Input-Variables might be a possible way to achieve this, they should only be available in the scope of this task and get deleted afterwards.
This works at least for UserTasks (we are using our own (User)TaskList which gets its parameters via Input-Variables)

@KeyKon sounds nice. How do I specify Input Variables via the REST API?

Mh, I think I kind of misunderstood what you want to do.
Our UserTasks get their InputParameter-Mappings in the model (fixed values or values derived from global process-variabels).

I don’t think there is a way to pass values at the start of a process instance to a specific task-scope in that instance, since this task-activity doesn’t exist at this moment.

A last possible way might be to delete these global variables after the worker task finished, via script or listener, but this might be kind of cumbersome…

Yes, I have thought about it and would not like to go that way.