Get the previous human task activityInstanceId



I would like to get the activityInstanceId of the activity (task) that lead to the current one.

How could i retrieve this value?


1 answer



Not sure a method exists to give you the previous task, where with previous task we define that task that is connected with the arrow to the current.

A couple of options are possible

1 - If your diagram is linear (activities in series) you could take the last executed task before the current.

2 - probably it's not what you want, but if you know the name of the task you can easily find the it's activityInstanceId.

Let us know if you need help with the api for 1 or 2



Submitted by mike_1989256 on Tue, 07/28/2020 - 16:18


No my diagram is not linear, so i can't use the first solution. my Diagram has the following structure:

start - > task A --[leads to one of the following]-> task B - task C --[both leads back to]--> Task A --.... and so on until a condition is met, then the process is finalized.

Having multiple targets to the task A, i would like in task B to identify the objects that were created by the previous task. (in the database i store the task id, but my problem is getting the previous task id so i could search for it in the DB)

i can't use pool variables (business or process one) because the values might get overridden. let's take the case where i want to transfer the id of an object created in task of actor A, the sequence is as follows :

if A send to B (ID 1) and C (ID 2),

then B send to A (ID 3),

and A send to C (ID 2 is overridden by a new variable - considering that i created a pool variable to store IDs for each actor)

C now has 2 pending tasks, both having the same ID of the created object