How to define variable that will be used in expression?

How to define variable that will be used in expression?
In properties i see Variables but no way to add some.

In modeller I put expression for flow:

But Camunda BPMN plaform screams ‘Cannot resolve identifier ‘dept’’.
I saw some doc that I create variable when I start process but this sounds weird - I want to create variables when I create model. Later I just fill these variables with values when I complete task.


I found this doc Camunda Best Practices - Handling Data in Processes and still understand nothing.

You can **dynamically** create such variables by assigning an object of choice to a (string typed) variable name, e.g. by passing aMap<String, Object> when completing the "Review tweet" task via the API:

Map<String, Object> variables = new HashMap<String, Object>();
variables.put("approved", true);
taskService.complete(taskId, variables);

Where? REST API use JSON not such format. But even so this is not possible to run process. I you click ‘start current diagram’ in modeler there will be error ‘Cannot resolve identifier xxx’. Variables needed.

you should first define variables and then use them in expressions.
you can define a process variable using this command :


Which ‘command’? Where I have to type this command?

you can call execution.setVariable in groovy script task,
refer to following links for more detail

In script? Really? We have 2021. I do not want to mess with ‘scripts’ and ‘classes’.
When I build software for users I always keep in mind ‘they do not want to mess with files - if they wanted, they would create software by their own’.

Generally questions here on the forum are assumed to be from the perspective of a Software Developer using Camunda to implement processes as part of a custom platform or some kind and scripts and classes are very much part of that. So the suggestion that @mrdavoodi64 gave you given the context makes perfect sense.

What you’ve done for far with camunda is completely unclear so far from your posts and beyond the fact that you’ve manged to work out what year it is, what you’re trying to accomplish is also a compete mystery.

So perhaps, you can take a breath and write a detailed account of…

  1. What you’re trying to accomplish
  2. what you’ve tried so far
  3. what you’re having trouble implementing.

You might get some help in that case.