Task instances are only automatically deleted when they
complete if this is specified in the associated task template from
which the instances are derived. This example shows how to delete
all of the task instances that are finished and are not automatically
deleted.
Procedure
- List the task instances that are finished.
FilterOptions fo = new FilterOptions();
fo.setSelectedAttributes("TKIID");
fo.setQueryCondition("STATE=STATE_FINISHED");
EntityResultSet result = task.queryEntities("TASK", fo, null, null);
This action returns a query result set that lists task
instances that are finished.
- Delete the task instances that are finished.
for (int i = 0; i < result.getEntities().size(); i++) {
Entity entity = (Entity) result.getEntities().get(i);
TKIID tkiid = (TKIID) entity.getAttributeValue("TKIID");
task.delete(tkiid);
}