Get Process Name in Java service
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2016 11:32 AM
We are using Enterprise Activiti 1.5
I'm trying to get the Process Name of the current process in Java service task but couldn't find any method, see method to get the process instance id by "execution.getProcessInstanceId()".
Any idea? Please let me know.
Thanks!!
- Labels:
-
Archive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2016 12:24 PM
Hi,
You can get it via process instance query API
execution.getEngineServices().getRuntimeService().createProcessInstanceQuery().processInstanceId(execution.getProcessInstanceId()).singleResult().getName();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2017 01:48 PM
Thanks for the reply Ciju!
Tried the code it gave me null pointer exception so tried to get the query count for the process instance
ProcessInstanceQuery pqry = execution.getEngineServices().getRuntimeService().createProcessInstanceQuery().processInstanceId(execution.getProcessInstanceId())
and the query count is 0.
We are using Enterprise Activiti 1.5
Regards,
Durai
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2017 06:23 PM
Hi Ramesh,
That is probably because the process instance is not yet committed into the database at the time of your query.
For example if you do query count in a script/service task in a process that looks like Start->Script->End it doesn't work.
Now if you make the script/service task "Async" and do the process instance query, it works.
Regards,
Ciju
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2017 08:35 AM
Hi Ciju,
Yes I had the query count logic in "Execution Listeners" start event in the task following Process Start. After marking the checkbox "Asyncronous" checked in the task where my script exists then I was able to get the query result.
When you got minute can you please throw some light on the purpose of the "Asynchronous" checkbox in the user task does.
Thank you very much for the help!!
Regards,
Ramesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2017 12:11 PM
Hi Ramesh,
Upon starting a process, activiti persists the data to database upon reaching the first asynchronous task. Hence the query was able to fetch from the name from the database!
It is explained here in detail Activiti User Guide ( section Asynchronous Continuations)
Regards,
Ciju
