currentUser() returns null in Call Activity


#1

Dear Camunda community,

In version v7.9.0-alpha2 I have a main process with user task and a call activity with the a user task inside. During execution of the call activity ${currentUser()} returns null, while the same variable returns a correct user in the main process. I have Input Variables mapped to all. What would be a proper way to pass currentUser() into a call activity?

Best regards,
Ilya


#2

Hi Ilya,

Is there an asynchronous continuation or other wait state between the user task and the point where ${currentUser()} is accessed?

Cheers,
Thorben


#3

Hi Thorben,

The main process has “asynchronous after” on user task (which works well with currentUser() and the same setting on further user tasks in a process after Call Activity. The Call Activity itself does not have any non-standard configurations (neither activity nor sub-process steps).I have a parallel gateway in sub-process if it is relevant.

Thank you.

Best regards,
Ilya


#4

Hi Ilya,

The currentUser context is only available in the transaction that is triggered by the user. That means, any EL expression that is executed by the job executor (i.e. after asynchronous continuation) and that uses currentUser fails. If you need to preserve that context, you could consider storing the current user in a process variable when the task is completed, for example by adding a task listener on the complete event.

Cheers,
Thorben


#5

Or model an outputparameter with name “userId” and value ${currentUser()}

Cheers, Ingo


#6

Hi Thorben,

Appreciate your response. I was trying to understand your explanation, but still struggling as probably do not have a good picture of the internal architecture. When you say

“to preserve that context, you could consider storing the current user in a process variable when the task is completed”

by task you refer to Call Activity as a whole or individual UserTasks?

Seems like in Call Activity I cannot capture currentUser() at any stage until Call Activity is finished.

Does it mean that in my case having two different UserTasks assigned to two different users inside Call Activity will block me from capturing both users?

Thank you.
Ilya


#7

Hi Ingo,

Thank you for your email. I believe this option would not work for my case as I am trying to capture users executing UserTasks within Call Activity…

Best regards,
Ilya