Can anyone recommend the best approach to delete process instance variables and associated history after the instance completes? My use case requires that the variable data exists only when the process instance is running. Once it completes I need to delete the variable data and all history. This doesn’t apply to all process definitions only a select few, so enabling this via configuration would be the best option.
Thanks @Ingo_Richtsmeier. This helps a lot. once the process completes all its data is moved to the history tables so this should prevent the variables existing in the history.
Thanks @Yana. How do I trigger this clean up for as specific process definition after the completion of the instance? What’s the post completion hook I need to integrate in order to make sure the data is deleted without causing a transaction issue?
I can see I can use the HistoryService to delete the history data for a specific process instance but just not clear when is a good place to call this method, can it be used in an ExecutionListener? Don’t think I can as that’s part of the existing transaction which could have a strange effect?
You need to configure historyTimeToLive in the process definition (1) and then you can either trigger the history cleanup manually (2) or configure it to run all the time/specific times (3).
Setting historyTimeToLive=0 will mean the historic process instances (and their data) will be ready for delete after they finished.