-
1. How to get the Task instance id ?
krisverlaenen May 14, 2011 7:52 PM (in response to a_nat)Hi,
You can cast kcontext.getNodeInstance() to WorkItemNodeInstance and use getWorkItemId() to get the id of the work item.
You can then get the Task instance itself from the TaskServiceSession using getTaskByWorkItemId(..).
Could you maybe share your use case why you need access to the task instance id? Maybe there is another workaround as well. It's for example easy to pass the task instance itself as a result parameter of the human task.
Kris
-
2. How to get the Task instance id ?
a_nat May 16, 2011 4:29 AM (in response to krisverlaenen)Hi Kris,
Currently we are calling an external webservice on the On-entry actions of human task, so we would like to pass in the task instance id as the unique correlation id.
Apart from the above, we would also like to inform the user of the task using an email service, so that he can look into the specific task instance.
Kindy let me know, if you think of better options of doing the above.
Regards,
Aparna
-
3. How to get the Task instance id ?
a_nat May 16, 2011 8:26 AM (in response to krisverlaenen)Hi Kris,
i'm not sure whether ((WorkItemNodeInstance)kcontext.getNodeInstance()).getWorkItemId() will return me a unique number every time for me to uniquely identify the tasks based on it.
Regards,
Aparna
-
4. How to get the Task instance id ?
krisverlaenen May 19, 2011 6:37 PM (in response to a_nat)Hi,
Yes, it will be unique for that session, or fully unique across sessions if you use persistence.
The getTaskByWorkItemId() method uses asynchronous communication, so you need to provide a response handler that will be called asynch. and return the result. Simply use the BlockingGetTaskResponseHandler if you want to get the result synchronously.
Kris
-
5. Re: How to get the Task instance id ?
npereira Jun 2, 2011 10:20 AM (in response to krisverlaenen)Hello Kris,
I have been experimenting on this but I haven't quite been successfull.
I attached some files with the BPMN and the java that I am using to debug the process.
The facth is that the Java code that is executed inside the bpmn, returns a WorkItem ID=2.
System.out.println("Inside HT node 1");
System.out.println("Process id is "+kcontext.getProcessInstance().getId());
WorkItemNodeInstance wi = (WorkItemNodeInstance)kcontext.getNodeInstance();
System.out.println("getWorkItemId is " + wi.getWorkItemId());
System.out.println("WorkNodeID is " + wi.getId());
System.out.println("WorkItem UniqueID is " + wi.getUniqueId());
System.out.println("WorkItem ID " + wi.getId());
String s2 = ""+kcontext.getNodeInstance().getId();
System.out.println("Node Instance id is " +s2);
But once I get the Task, from de debug java class, the task WorkItem ID=1.
client.getTask(TID, responseHandler);
Task task = responseHandler.getTask();
TaskData td = task.getTaskData();
System.out.println("Task WorkItemID "+td.getWorkItemId());
BlockingTaskOperationResponseHandler eresponseHandler = new BlockingTaskOperationResponseHandler();
TaskOperationResponseHandler respHandler = null;
client.start(TID, "krisv", respHandler);
client.complete(TID, "krisv", null, eresponseHandler);
So there is no way to get a correlation between these two.
So how can I get this working?
-
ProcessWorkItemTest.java.zip 1.1 KB
-
sample.bpmn.zip 1.4 KB
-
-
6. Re: How to get the Task instance id ?
jjsaguit Oct 28, 2013 4:11 AM (in response to npereira)I'm wondering if you got this solved, I'm having the same problem
-
7. Re: How to get the Task instance id ?
a_nat Nov 13, 2013 5:13 AM (in response to jjsaguit)https://issues.jboss.org/browse/JBPM-4147
Currently No, we can't get it using kContext, which is a pain. Few other BPM engines support it and as far as I remeber jboss 3 supported it too.
Have created [JBPM-4147] Able to use 'Task Variables' as expressions in Task properties - JBoss Issue Tracker