Alternative multiple items in a task

It’s entirely up to how you want to handle the data; the system is designed and intended to be flexible and provide multiple ways to solve a problem. I strongly suggest you read our documentation - not everything can be answered in an introductory video series, but the docs cover all these topics in depth. You can learn all about input/output mappings here:

As mentioned (and described in the linked documentation), the variables defined with a form attached to a user task are automatically added to the global scope (doc reference here). Typically you only need to configure mappings if you need to do something additional with the data.

For your use case of adding multiple values in a single form, and wanting to collect/track/use those throughout the process, I would recommend looking into the FEEL context type, which are similar to JSON objects. For instance, maybe an output mapping with the FEEL expression =append(globalListVariableName, { price: priceFormVariable, product: productFormVariable, quantity: quantityFormVariable }), which I would expect to create a structure like:

  { price: 0, product: 'string', quantity: 0 },
  { price: 1, product: 'string1', quantity: 0 },

(Note: I have not tested this, but that’s how I would start approaching it.)

Should I do this [
{ price: 0, product: ‘string’, quantity: 0 },
{ price: 1, product: ‘string1’, quantity: 0 },

] or does Camunda do it automatically? I didn’t understand why there were colors already in your list.

That data structure is created by the FEEL expression. You don’t have to build and use a data structure like that - that is just how I personally would approach it - but you must write the appropriate FEEL expressions either way.

There were no colors in my list when the process started. The screenshot I shared is after running the process. Attached is the exact model I ran in Play mode. Import it, run it in Play Mode!

add-dynamic-items.bpmn (5.3 KB)

Thank you. Since I would have 3 variables, would I need to create 4 output values with the list? Could I then input the list again as input for my 3rd task, and have a new list as output if any changes are made? And finally, input the newly modified list into the task as input. Is that possible?

You can structure the data however you need to accomplish the task at hand, with as many variables as you need. As long as the variables are in the same scope, you can consume them with future tasks.

I somehow don’t understand. Do I have to input four variables for Output 4 because you mentioned two variables, once the list and the colors. And what if I only want to see the list in the next output? Should I only input the name of the list in that case ?

I am missing a lot of context for those questions, so I’m not sure I can properly answer them. It depends entirely on what you want to do, what your expectations for the results are, and how you’ve structured your forms and/or job workers. It’s also difficult because this isn’t a pattern I would recommend, because it requires your customers to log in to Camunda, not just your employees.

In order to help any further, you’ll need to share the full model (easier to upload the full XML than to take numerous screenshots), describe what you are expecting to happen, and describe what is happening, and we can help close the gap between your expectations and the current result.

Hello! Is it possible for me to send this privately

Is there any proprietary or secret information in the model?

I can send the process here. I can explain to you what needs to be done in the process. In the first task, you enter how many items you want. In the second task, you provide a name and price for each item. In the second task, you double-check if everything is spelled correctly. In the last task, you read the items again. As I described to you yesterday, the values get overwritten.
items.bpmn (10.5 KB)

You didn’t enter any input mappings for the tasks, so the expected result is for the variables to be overwritten. Focus on just the second task, ignore the 3rd and 4th tasks for now: when the second task is complete, what do you want/expect the resulting data structure to look like?

What I expect is for them to be stored in a list

Have you tried the FEEL expression I shared a few replies above?

Not yet, because I’m unsure. During your process, you had two values as output in the ‘add item’ task, and to be honest, I don’t know if I need to insert three variables because I was uncertain.

That was explained earlier:

The fields you define in your form are automatically available as variables when the task completes. To avoid overwriting them you need to store their values elsewhere (or the next time the form is completed the values are overwritten because the names are the same).

Do I understand correctly that I have to write: =append(List, { Name: field_Name, Price: field_Price})?

Should I use the name of the list as input in the last task?

I’d like to encourage you to experiment and try it for yourself. It’s very easy to test with Play Mode, and Play Mode shows detailed logs of what is happening to each variable at each step, which will lead to a greater understanding of the product. I also recommend not worrying about the third task until you have the second task working as you want it to.

That FEEL expression will append the context (object) { Name: field_Name, Price: field_Price } to the list (array) variable List. In the output mapping, the “Process variable name” should be List also, so it’s appending to the same list instead of creating an entirely different list every loop. Try it in Play Mode and see what happens!

Hello, I have tried to create a list and tested it in play mode. However, it seems that the values are not being stored in the list. My code line is ‘append(List, {Name: field_Name, Price: field_Price})’. The List keeps showing up as null. I’m not sure why the values are not being saved in the list.

Can you share a screenshot of your task definition with the input and output mappings expanded? (Or share the XML again?)

Hello, I am providing you with the file.
items(1).bpmn (10.5 KB)