Get ActivityInstance from another task

1
0
-1

Hi everyone.

I'm working in an email notification task.

I'm trying to know if a task is assigned to a user or not.

If the task is assigned to a user I need the email of this user to send the notification, or if the task is unassigned I'm sending the notification to all the possible users.

If I want to extract this information from another task, i found the method getHumanTaskInstance from the processAPI(), but I need the activityInstanceId from the other task to obtain the information.

How can I get the activityInstanceId from another task?

Thanks.

Jorge

1 answer

1
0
-1
This one is the BEST answer!

Hello,

What do you have to search the another activity instance? A CaseID and a task name ?

So use the Search operation (I'm not sure about the ActivityInstanceSearchDescriptor constant, have a look in the javadoc)

SearchOptionsBuilder searchActBuilder = new SearchOptionsBuilder(0, 1);
searchActBuilder.filter(ActivityInstanceSearchDescriptor.ROOTPROCESSINSTANCE, MyCaseId);

searchActBuilder.filter(ActivityInstanceSearchDescriptor.NAME, "MyTaskName");

SearchResult searchFailedActivityInstance = processAPI.searchActivities(searchActBuilder.done());

if (searchFailedActivityInstance.getCount()>0)

activityInstanceId = searchFailedActivityInstance.getResult().get(0).getId();

By the way your use case seem to be take into account by the Email User job in TruckMilk

https://community.bonitasoft.com/project/pagetruckmilk-execute-jobs-intervalle

best

Comments

Submitted by jpineda_1 on Thu, 08/20/2020 - 18:46

Hi,

I tried that code on my project and it worked like a charm.

Thank you very much!

Regards.

Submitted by Pierre-yves Monnet on Thu, 08/20/2020 - 19:19

Super! Glad to have helped!

Notifications