User Tasks with Return value

Hi everyone,

Quite new to Camunda and seeking some advises on the Camunda-way.

My current diagram layout is:

  • Start event (context/variables);
  • Condition (is_approval_required)
  • When is_approved_required = yes, I create a User Task;
  • The flow interrupts and wait for the user to claim and complete the task.

How can I have different values as results of the Human/Task step?
Why when I define an output in the Task step, this is not available in the following block?

And how should I proceed if I want the user to get a task assigned to it but I want to halt the execution of the flow on the wait of a system message:

[ User Task ] —> [ Wait for external Event ] → [… more… ]

How do I route an external event to a already running-instance in Camunda?
how do I indicate that the external event is for the that specific instance?

Last but not the least, having a technical step on a business process such as the ones that I am working on, doesn’t sound too correct.
I would expect a task to be assigned to a user, and the task itself would halt until an event comes through …

anyone that could give me some good advises on this pls?

Thanks in advance,
GC

Hey @gianluca ,

Welcome to the universe of Camunda. Let me try to help you with your questions:

How can I have different values as results of the Human/Task step?
I am not sure exactly sure what you mean. For the input of the user you must create a form. There are various options how you can achieve that. If you want the User to interact with Tasklist, I think an easy way to start are form fields. Or if you are okay with String values you could use the new function of the Camunda Modeler to create forms and deploy those together with your bpmn diagram. If you have decide the way you like to build your forms, you could then have a variable, that stores the different values form the usertask.

Why when I define an output in the Task step, this is not available in the following block?
If you define a variable in the Usertask this variable is available in the process afterwards. So if you create in the user task the variable age you can use the variable in Expressions to see if it contains a certain value etc.

And how should I proceed if I want the user to get a task assigned to it but I want to halt the execution of the flow on the wait of a system message:
This is a little bit unclear. You want to assign the user and then pause the execution (meaning the user is not allowed to work on its task) or do you want to pause the process after the user finished its task or do you want that both things need to happen at the same time? I think this can be solved easily by using BPMN symboles, like for example the message receive event.

How do I route an external event to a already running-instance in Camunda?
This depends on the event type. But if you use messages for example you can define correlation keys for the message, so it finds its process instance.

how do I indicate that the external event is for the that specific instance?
Again not sure what kind of event you are talking about. But again correlation keys for messages would help here.

Last but not the least, having a technical step on a business process such as the ones that I am working on, doesn’t sound too correct.
I would expect a task to be assigned to a user, and the task itself would halt until an event comes through …

A usertask always halts until a user completes it. Not sure if that is what you mean.

I hope that helps. Cheers
Nele

2 Likes

Hi Nele,

Thanks for your reply.

Let me try to discuss the previous points with the help of an example.
This is one of the workflow that I would like to implement:

I am planning to interact with Camunda by using a bespoke .Net Core C# solution. It will leverage the Camunda C# client library (GitHub - camunda-community-hub/zeebe-client-csharp: Contains an Zeebe C# client implementation.).

When my bespoke solution will receive a DocumentUploadedEvent, it will use the C# Camunda client to create a new instance of a process. AFAIK, I’ll have to pass on an initial context as part of this step. This will provide a set of variables that the first component in the workflow will be able to use.

Let’s assume that the “Review evidence” task presents a bespoke screen to the user, where it is possible to either approve or reject an item. The approve or reject actions will call into a bespoke API that will raise an event. The event might get delivered long after the task is completed in Camunda. So, the actual outcome should be evaluated when the EvidenceVerifiedEvent is routed into the workflow.

I guess my real question is how can I assign the task and simultaneously wait for an external event? Do I need to have two different branches running in parallel?

Thanks in advance,
Kind Regards,
Gianluca.

As alternative solution, I was thinking something on the line of:

Hey @gianluca ,

Well I have to admit i have no experience with .Net.
The first thing I notice is that you linked the .Net client for Zeebe, Do you plan do use Zeebe or Camunda Platform? If you want to use Camunda Platform you can find a external task client for .Net here.

Yes you can start a process instance from your client with information that can be used in the following process. This is correct.

I am not really sure how bespoke event works. So you want that the user task is finish and evaluated when the EvidenceVerifiedEvent arrives as well? The model you included would not do that but rather start a second instances.

So if you want the user task to be completed and the event to be received you could to something like this: example-forum-usertask-and-event.bpmn (9.3 KB)

Just from the case I am wondering if it would not be better to use the EvidenceVerifiedEvent to then trigger the complete from the user task. So to connect the EvidenceVerifiedEvent with the complete call of the User task to Camunda.

You use the bespoke frontend right? So maybe to trigger the complete call for Camunda’s user task should not happen when the user completes the task in bespoke but when the event is triggered.

I hope that helps
Kind regards
Nele