How to use scripting task to get the task id from the execution context

I am trying to define a process like above with an intension to get the task id and then send an email with that task id. As per my expectation, tokens are moved to the Send Email Script task, once the user task is activated. However, I am unable to get the desired task information in my implemented Script Tak in Java. In my Jave code, I am getting the script value, as what I mentioned during my design. My expectation is to get the evaluated value of my script at run time. Please let me know, whether this can be achieved using the Script Task and what to write in the Headers for that.

How exactly are you trying to send the email via a script task?
Normally under the implementation section of the properties you can define to use a feel expression and the under script you define the feel expression that gets assigned to your result variable.
You can also use a job worker to execute your script task. Is this what you’re trying to do?
Why are you not using a service task or a connector for sending an email?
Then you could access all variables that are available in your process instance.

Hi @rohwerj Thank you for your quick reply. I am planning to get the task id as and when user task is created in Zeebe engine. That is the reason I have placed an attached boundary timer event to assign it to a script task. My idea here is to get the task id in the script task and then call a custom connector to send the email. Alternatively, I can also implement the Job worker for my script task and send email from there. I know, I can use task REST API from my Job worker to get the task id by passing the processInstance and task definition id, but I want to avoid that in case I can get the task id directly in my Job worker. Please let me know, in case this answer your queries related to my earlier post.

Hi @Suman_Paul. I don’t think you can directly access the taskId in the script task of Camunda8. In Camunda7, you maybe would be able to do something with listeners, but even of that I’m not sure.
So if nobody else has some more insights, I think your best bet is to load it via REST API.

Hello guys! \o

In Camunda 7 we were able to search for the task id through the Task Service, however in Camunda 8, i’m not very knowledgeable enough to give you an adequate answer.

William Robert Alves

Hi @Suman_Paul,

I’m trying to understand the use case here.
If I understand right, you want to send an email with a link to the user task, when the user task is created. Is that right?

Hi @aleksander-dytko
You understood the requirement correctly.

1 Like

Did you find a way to get taskID ?