I have some user input coming to the process and i want to pass those values to the external task worker. and in another use i want to pass some hard coded value from process to the external task worker in camunda 7 version. Do i need to use Input pr Field Injection in the modeler for the second scernaio.
When the return is null it means that a process variable with this name was not found.
remembering that you must use the method passing the name of the variable as an argument in like this: getVariable(“processVariableName”)
Try creating a process variable directly through the camunda cockpit, and placing a value on it to be searched for and handled by your worker.
You can do a test as follows… after the process starts, place a “user task” just to stop the process, and then you can create a process variable while your instance is stopped.
After this, complete the user task, and check if your worker will correctly search for the process variable.
If you can fetch the value, it is because your input is incorrect for some reason.
For the worker to do this search with getVariable, you will have to have this variable as a process variable.
I can see the variable in the cockpit which i added in the sevice/external task…and its says scope “As my task name”, but i am trying to retrieve this variable in the java code in the worker. Do i need to change scope or something to retrieve this variable in the worker.
I am using “externalTask.getVariable(“test”);”
I believe that the process variable needs to be in the same scope as your External task, so that you can search for this variable.
I’m not sure about this, but I believe so.
Is the process variable you want to look for not in the same scope as your external task?
I believe that the variable scope for external tasks works the same way as other types of tasks.