cancel
Showing results for 
Search instead for 
Did you mean: 

Activity Name of the current Activity

zobbl
Champ in-the-making
Champ in-the-making
Hi there,

currently I'm displaying the current task and all the completed tasks from the running instance

the historyService gives me access to all completed tasks from the given instance. There I can access the activities Name, which is defined in the ProcessDefinition.
But for the current task I have to use the activityID from the processInstance that is running. Problematic as the ID and the Name are similar in some way but not equal.

Is there a way to add the activityName to the processInstance or to query the name in some way with the activitiyID?

The DeploymentService doesn't give me any hint how to do so, except for one solution:
Querying the ResourceName of the deployment and parsing the XML-File.
It isn't that bad, because I'm using Activiti with Grails and Groovy provides me a nice and neat way to access XML-Structures, but I think it's a bit oversized just to display another String

Is there a smart and smooth way to do so?

I hope you understand my problem Smiley Wink
4 REPLIES 4

jbarrez
Star Contributor
Star Contributor
When you query for tasks, you get a org.activiti.engine.task.Task object back, which has a name attribute you can access.

zobbl
Champ in-the-making
Champ in-the-making
Thanks for your reply, but it doesn't seem to work.

The description of Task implies, that only usertasks can be queried. But I have only Script Tasks (User Tasks are likely to be added in the future, but not for now).

Or I'm doing something wrong.

I tried
taskService.createTaskQuery().processDefinitionName(processName).list()
and

taskService.createTaskQuery().processInstanceId(currentInstance.id).list()
All I get is an empty list. So the passed values instanceId and procDefinitionName are right and the query was executed as intended.

Another, maybe important, information is, that all my tasks are asynchronous, as I'm using Grails and want the page to load and display all the information on the fly

jbarrez
Star Contributor
Star Contributor
Ok, my mistake: I thought you were talking about user tasks.

There is no way of getting the name of a script task.
There is however a workaround, by casting the RepositoryService to the RepositoryServiceImpl you can access a method that allows to inspect the ProcessDefinition and its activities programmatically. That should dp the trick, I believe.

zobbl
Champ in-the-making
Champ in-the-making
Alright thanks Smiley Happy

Is it planned for the future, that all types of tasks can be queried for their name?