Purge Old Completed Process Instances
Introduction
This guide explains how to automate the deletion of old completed process instances in Joget using a Bean Shell script. By scheduling this script, you can maintain optimal server performance by removing outdated data.
How does it work?
To keep your server performance optimal, it's essential to purge old completed process instances regularly. The following Bean Shell script automatically deletes process instances older than 12 months, helping you manage server resources effectively.
You can adjust the script to fit specific conditions or retain data for a different duration.
Integrate the script into a scheduler job or process tool to automate the purging process. If needed, ensure the script is configured to filter by specific app or process IDs.
The script retrieves process instances and compares their start times to a cutoff date. Instances older than the cutoff date are deleted, and a log is generated for the removed instances.
You may modify lines String appId =
null
;
//to filter by specific appId
to String requester =
null
;
if you would like to filter according to specific conditions.
You may also modify line int
months =
12
;
//retain last X months data AKA remove data older than X months
and change how many months of the latest process instances you would like to retain.
Sample server log
After running the script, the server log should display entries similar to the following: