cancel
Showing results for 
Search instead for 
Did you mean: 

How to retrieve the task id and name in a service task?

imoraru
Champ in-the-making
Champ in-the-making
How can I get the task id and the task name for a service task?

 
public void execute(DelegateExecution execution) throws Exception
  {
    String name = ???;
    String id = ???;
  }
Also, how would I access the process instance?

I'll appreciate your help.
TIA
Ion
4 REPLIES 4

atifelkhachine
Champ in-the-making
Champ in-the-making
Hi,

This should work :


public void execute(DelegateExecution execution) throws Exception
{
@Override
public void execute(DelegateExecution execution) throws Exception {
  ExecutionEntity ee = (ExecutionEntity) execution;
  String name = (String) ee.getActivity().getProperties().get("name");
  String id = ee.getActivity().getId();
  System.out.println(name);
  System.out.println(id);
}

Best regards,
Atif

imoraru
Champ in-the-making
Champ in-the-making
It actually works!
Thanks Atif.

Ion

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
But keep in mind that this requires the use of non public classes so they might change without notice!!!

pedro1
Champ in-the-making
Champ in-the-making
You can also use:


execution.getCurrentActivityId();
execution.getCurrentActivityName();