Variables (Data) in Tasks

What is the difference between Forms, Input, Output? I thought Forms included Input and Output. There are no detailed explanations about it. Thank you

I’m not an employee, nor a full expert, but here’s how I would explain it.

Input - Allows you to rename a Process Variable to the name needed within a task for that task to be completed.
Form - Used within a Task to present to a user the variables of that task, allowing them to potentially change the values of those variables.
Output - Allows you to rename a Task’s variables when storing them as Process Variables.

Input and Output a particularly important for Service Tasks and Connector tasks. You might have a connector that requires “base_url” but your process has it stored as “InterfaceURL” – you would create an Input that maps the InterfaceURL to base_url so that your re-usable task doesn’t need to be rewritten. Similarly, the “response” from your task might be more useful to your process if it were called “InterfaceAnswer” – Output allows you to do that mapping.

Hope that helps

Is what I did with “Form” incorrect? I used it in the process. In one task, the user enters their last name, and in the next task, it is only read, so it is set to “disabled” to allow only reading in the next task. Later, I plan to use JSON Form in the task. What are process variables? I find it strange that they were not covered in the Academy videos. I’m having a lot of difficulties.

I’m not sure what you mean

So you have a simple process: Start → Collect Information → Review Information → End
At “Start” you would likely not have any variables. When the user clicks “Run Process”, Camunda will create a token (pointer of where in the process we are at the moment), evaluate the activities to be completed as part of starting one Instance of the process, and move the token to the next task.
“Collect Information” wouldn’t have any inputs because you are not going to map a variable from the process into the task.
While in “Collect Information” the user would have a form. This form would define a variable.
Since this is a simple process, you don’t need to rename the variable created in the form to a different name for use elsewhere in the process; therefore you wouldn’t use an Output
When the user clicks “Complete Task” on the form, Camunda will move the token to the next task.
We’re now in “Review Information”
Again, since we have a simple process, we don’t need to rename anything, so we don’t fill in any Input mapping.
In this task, you would want a different form, where the name field is disabled.
The user clicks complete, and Camunda will again move the token to the next item in the flow, which is “End” There would be no output mapping, because you don’t want to rename the variable.
When the token hits “End” the Process Instance is completed, and removed from the active Instance list. The token is destroyed.

Is that clearer?

I understand, but do I have to necessarily use input and output in the process modeler, or is it sufficient if I use forms?

In the simple process I described above, you would NOT use Input or Output for any of the tasks.
You COULD, but it wouldn’t make a lot of sense to. It would just make things more confusing.

This page might help…

When does it make sense to use input and output? I don’t understand the difference and when to use each. I would appreciate your help.

See the example above…

If you are using the same service task (rather than a user task) in multiple different processes, then it might be expecting a variable with a specific name. Rather than rewriting the script in every place that you want to use it, it might make more sense to use an Input or an Output to change the name.

Since EmpNum makes more sense in our process, we’re going to use that as our variable name with the form for “Get Employee Number”, but the script that is being run in “Retrieve Employee Name” requires an input of id not EmpNum. So we’ll use an Input to change it to id.
Similarly, that script returns a variable called Surname, but that doesn’t make a lot of sense to the people building this process, so we’ll use an Output to change it into a variable called lastname, which we will then use on the “Confirm Employee Family Name” form.

Is that clearer?

Do I understand correctly that it only applies to Service Task Input and Output, or is it somewhere else as well? It’s like in Java, where you expect a value and it returns the value. Now I understand. Thank you very much. Can I understand it as a Service Task being an automated task that is triggered by programming code?

It applies to any task, but I think it would be unlikely to see an Input or an Output on a User (Human) task, since you would be defining the form specifically for that task.

However, it’s possible to use the same form over and over, so it might be done, especially if you have separation of responsibilities, where one team is managing the Forms and another is managing the process.

A Service Task is typically a program task, which could be configured by Connectors (eg. Making a REST call). Since the Connectors are explicitly designed to be reused a lot, they use predefined variables for what they want to receive and what they provide back, so it’s almost 100% chance that you will use Input and Output mapping on a Connector (The connector’s variable name won’t necessarily make sense in your workflow)

A Business Rule task is also a program task, usually implemented with a Decision Model Notation (DMN) diagram. These are usually made up of a table that contains Input Criteria and Output values. These can be thought of as a “Truth Table” and Parameters. If the Business Rule is “And” and you have two Input Criteria (boolA and boolB), then you would have 4 rows in your table:

a | b | Output
F | F | F
F | T | F
T | F | F
T | T | T

The Camunda Engine can evaluate the Business Rule (which can be a LOT more complex than “AND”) in a Business Rule Task, and provide the Output into the overall process as a Variable to be evaluated by one of the Gateways, or used in one of the User (Human) tasks.

Inputs are used to transform a Process Variable (a Variable that is used in multiple Tasks) so that the are in the form that is appropriate for that Task (or Job) to use. Outputs transform variables that the Task had into the form appropriate for the overall Process.

Translate it into English, please. I finally understood it. Thank you. How do you add, for example, a Java code in a task? You explained it really well.

Hi @FC_Catalonia,

This has two steps. First you create a Java program in your favorite IDE using a framework with a Zeebe client, for example Spring-Zeebe

Here, you configure the connection to the Zeebe cluster and expose a method of your code as a JobWorker with a task type: GitHub - camunda-community-hub/spring-zeebe: Easily use the Zeebe Java Client in your Spring or Spring Boot projects

In the Service task of the process model, you reference the task definition type from the job worker: Service tasks | Camunda 8 Docs.

Then you run your java program. It will start an infinite loop to work on service tasks with matching task definition types.

Hope this helps, Ingo

1 Like

If the inputs and outputs remain the same throughout the entire process, forms should be sufficient. Can service tasks be performed by humans?

Thank you very much. Is there a video available that explains this, for example, in the Academy videos?

Hi @FC_Catalonia,

it’s available as the “Camunda 8 - Getting Started with Microservice Orchestration” tutorial: https://academy.camunda.com/c8-getting-started-microservice-orchestration

Hope this helps, Ingo

Would it be sufficient if I see the section “Create Job Worker”?