I am new to Flowable and I have been playing with process instance queries for a couple of days now. I haven’t found a way to filter the process instances that have been deleted and/or terminated, perhaps using the “deleteReason” or something like that? Is this possible? Thanks!
you can use the
HistoryService to create a
createHistoricProcessInstanceQuery() and filter for
Thanks for you quick answer! Do you happen to know if there is any way to tell the difference between an instance that was deleted “manually” (i.e. using the Java API with a custom reason) and another that was terminated by an end terminate event? As far as I know, in both cases they are treated as deleted, that is, both set a value to “deleteReason”.
I think that one difference could be the value of “endActivityId” (null in the case of a manual deletion), but again I am not sure I can use that in the query?
HI @nadaesposible ,
“deleteReason” will have null when the process ends with an end event and get a value “process instance deleted” when a user terminates it manually in the flowable admin.
if it is terminated by API then it gets the custom values passed in the API
That makes perfect sense, yes. However, would I have to query the database directly? I haven’t found a way to check whether the reason is empty or not using the Java API. Again, I not an expert and might have missed it.
My workaround is to handle this using variables and send them to query. Not idea, but I think it’ll do.
Unfortunately, i am only using the rest API and i get this information in the response and I am surprised to know that this information is missing in the java API
for more information on how to get this from the rest API can be found here
REST API · Flowable Open Source Documentation
I believe the Java API is actually returning the info, but it’s not giving me the change to use it as a filter in query object. I could know, once I get the results, which process instances were terminated or deleted based on the delete reason, and could use that to filter, etc., but that would mess with the pagination, and would have to fetch all the deleted process instances even if I only needed the terminated ones, for instance. Not ideal.
I have been tempted to take a look at the source code to see how difficult would be to add this feature or if it even makes any sense. I sometimes wonder if knowing if a process was terminated is more a business use case than a general one.
Anyway, I am digressing now…