How to get taskId?

Hello,

I created a workflow to send email to users and notify them to complete user task in camunda.
Here is the flow:
step1: start event
step2: service task(send email to user)
step3: user task(user need to complete a form)
step4: end task

My question is when I send an email, I want to add the url of the task in the email.
url example: http://localhost:8080/camunda/app/tasklist/default/#/?task=2fafee2-2fb1-a112-a1f322f;
How can I get the taskId in the end of the url?

This is my code
public void execute(DelegateExecution execution) throws Exception {

	String subject = (String)execution.getVariable("subject");
	String receiver = (String)execution.getVariable("receiver");
	String cc = (String)execution.getVariable("cc");
	EmailManager.send("urlexample:",subject,receiver,cc);
}

Thanks

Hi @tzju1111
I think the best way to do this is using a Task Listener and send the mail within this Task Listener Delegate Code (e.g. on create of the Task). Within your service task you do not have the user task id yet.
Please see https://docs.camunda.org/manual/7.7/user-guide/process-engine/delegation-code/#task-listener

Best
Felix

Thanks. Sending email within Task Listener works.