External Task and Process input parameter

Hi,

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.

Hello my friend!
Welcome to Camunda Community \o

Below I am leaving the link to Camunda’s official documentation, which explains step by step how to use external tasks.

I hope this helps!

William Robert Alves

I am trying to retrieve variables using ExternalTask (Camunda Platform Javadocs 7.15.19-ee)

using getVariable() or getAllVariables()…

but i dont get the variable value. I get null and in the process, I am passing variable in the Input field.

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.

William Robert Alves

1 Like

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”);”

Hello my friend!

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.

William Robert Alves

Can you post a screenshot of this?
Can you post your testing BPMN file?

<bpmn:process id=“loan_process” name=“Granting Loans” isExecutable=“true”>
<bpmn:sequenceFlow id=“SequenceFlow_0nww3wx” sourceRef=“StartEvent_1” targetRef=“Task_1lvjtd4” />
<bpmn:serviceTask id=“Task_1lvjtd4” name=“Retrieve customer credit score” camunda:type=“external” camunda:topic=“scoreProvider”>
bpmn:extensionElements
camunda:inputOutput
<camunda:inputParameter name=“test”>DemoExample</camunda:inputParameter>
</camunda:inputOutput>
</bpmn:extensionElements>

I was not able to post whole xml file, just posted the part which shows the variable details.

This is resolved.

solution : No need to specify any “variable-names:” in the client application.yml.

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