There are two ways to do this, one directly in the system DB and one with an API call.
For **Delete via Public API**
you can build a process/App around the first version, you Public API: [void deleteCompletedCase(ICase completedCase) throws PersistencyException][1]
A simple script which deletes old cases could look as follows:
public class HistoricCaseDeleter {
public static void doIt()
{
CaseQuery oldCasesQuery = CaseQuery.create().where()
.state().isEqual(CaseState.DESTROYED).or()
.state().isEqual(CaseState.DONE).or()
.state().isEqual(CaseState.ZOMBIE)
.and()
.startTimestamp().isLowerThan(new java.util.Date(2010, 0, 1));
for(ICase oldCase : Ivy.wf().getCaseQueryExecutor().getResults(oldCasesQuery))
{
Ivy.wf().deleteCompletedCase(oldCase);
}
}
}
<br/>
**Delete directly in System DB**
You may clean up cases and tasks in Done (2) and Destroyed (3) state as follows:<br/>
<br/>
1. Stop Xpert.ivy Axon.ivy server v4.xv4.x or later
2. Backup your DB (of course)
3. Execute to know how many cases you are about to remove:
SELECT COUNT(*)
FROM [YourIvySystemDb].[dbo].[IWA_Case]
WHERE State = 2 OR State =
4. Execute to remove them:
DELETE FROM [YourIvySystemDb].[dbo].[IWA_Case] WHERE State = 2 OR State = 3
5. You may shrink your DB to save disk space (e.g. MSSQL manager tool can do that)
6. Start XIVY server
For the second version, you can build a process/App around the Public API:
void deleteCompletedCase(ICase completedCase) throws PersistencyException
Deletes the given completed case and all belonging objects (tasks, workflow events, notes, process data etc.).
A completed case is a case that has the state CaseState.DESTROYED or CaseState.DONE or CaseState.ZOMBIE.
This method can be used to clean up the database.
Warning: This method deletes the data of the given case permanently. It is not possible to restore the data afterwards.
Parameters:
completedCase - the case to delete permanently. Must not be null
Throws:
PersistencyException - if persistency access fails java.lang.IllegalStateException - if the given case is not in state CaseState.DESTROYED or CaseState.DONE or CaseState.ZOMBIE
API:
This public API is available in IvyScript and Java. It has the visibility ch.ivyteam.api.IvyScriptVisibility.EXPERT.
Security:
SESSION OWNS CaseDelete PERMISSION OR OWNS CaseDelete@SYSTEM PERMISSIONAxon.ivy server again
[1]: http://developer.axonivy.com/doc/latest/publicApi/ch/ivyteam/ivy/workflow/IWorkflowContext.html#deleteCompletedCase-ch.ivyteam.ivy.workflow.ICase-