cancel
Showing results for 
Search instead for 
Did you mean: 

Obtain the current TaskId

variag
Champ in-the-making
Champ in-the-making
Hello guys,

How could I obtain the current taskid of a process in execution?

I have tried it with this code but throw an exception: "The task with this <id> doesn't exists"

public void notify(DelegateExecution execution) throws Exception {
[…]
String taskId = execution.getId();
List<FormProperty> formProperties = ProcessEngines.getDefaultProcessEngine().getFormService()
.getTaskFormData(taskId).getFormProperties();
[…]
}

Thanks for your replies!

Bye!
7 REPLIES 7

variag
Champ in-the-making
Champ in-the-making
Someone? If is necessary I can re-formulate the question.

Bye!

hassang1
Champ in-the-making
Champ in-the-making
execution.getId() will return the execution Id "not task id"

execution is different than task

Please can you explain what exactly you want to achieve?

variag
Champ in-the-making
Champ in-the-making
I want the current taskId for obtain the formproperties of the task. I have created a custom FormProperty and I want set it with data that I collect before in other variables of the process execution.

Thanks a lot!

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
Like bosted above:

execution.getId() will return the execution Id "not task id"

variag
Champ in-the-making
Champ in-the-making
I have changed the ExecutionListener for a TaskListener but the exception persists Smiley Sad .

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
code?

variag
Champ in-the-making
Champ in-the-making
public class PerDiemButtonFiller implements TaskListener{

public PerDiemButtonFiller(){
  super();
}

public void notify(DelegateTask delegateTask) {
  ActivitiUserPerDiem activitiUserPerDiem = (ActivitiUserPerDiem)
    delegateTask.getVariable("activitiUserPerDiem");
  ActivitiNationalPerDiem activitiNationalPerDiem = (ActivitiNationalPerDiem)
    delegateTask.getVariable("activitiNationalPerDiem");
  ActivitiForeignPerDiem activitiForeignPerDiem = (ActivitiForeignPerDiem)
    delegateTask.getVariable("activitiForeignPerDiem");
  ActivitiLocomotion activitiLocomotion = (ActivitiLocomotion)
    delegateTask.getVariable("activitiLocomotion");
 
  String taskId = delegateTask.getId();

  List<FormProperty> formProperties = ProcessEngines.getDefaultProcessEngine().getFormService()
    .getTaskFormData(taskId).getFormProperties();
  Iterator<FormProperty> it = formProperties.iterator();
  while(it.hasNext()){
   FormProperty formP = it.next();
   if(formP.getId() == "id_button"){
   PerDiemButtonFormPropertyRenderer obj = (PerDiemButtonFormPropertyRenderer) formP;
   obj.setUserPerDiemVariable(activitiUserPerDiem);
   obj.setNationalPerDiemVariable(activitiNationalPerDiem);
   obj.setForeignPerDiemVariable(activitiForeignPerDiem);
   obj.setLocomotionVariable(activitiLocomotion);
   }
  }
}

}