IBM BPM, V8.0.1, All platforms > Programming IBM BPM > Developing client applications for BPEL processes and tasks > Developing EJB client applications > Developing applications for human tasks

Delete task instances

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

  1. 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.
  2. 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);}

Developing applications for human tasks