Deleting Case Objects by Case Reference

Within a process, you can delete one or more case objects for which you have the identifying case reference(s).

Prerequisites

The process must already contain a data field containing either:

  • a single case reference to the case object that you want to delete.
  • an array of case references to a set of case objects that you want to delete.

If a case object that you want to delete has any association links to other case objects, you must delete those association links before attempting to delete that case object. If any case object has any active links to other case objects, the entire delete operation will fail - no case objects will be deleted.

Note: Best practice is to avoid deleting case objects at all, but if you must do so, to delete only a single case object using a single case reference. For more information, see Reasons to Avoid Deleting Case Objects.

Procedure

  1. Add a service task at an appropriate point in the process.
  2. On the General tab of the Properties view, set Service Type to Case Data Operations.
  3. Select Change or Delete Case Object(s) Using Case Reference Field.
  4. In the Case Reference field, select the data field that contains the case reference(s) that you want to delete.
  5. In the Operation field, select Delete Case Object(s).

What to do next

  1. (Optional) Add appropriate error handling to the service task boundary to deal with the following specific errors that may be returned by the Delete Case Object(s) operation.
    Error (Error Code) Description Possible solutions
    CaseOutOfSyncError (CaseOutOfSyncError) A case object referenced from the Case Reference Field has been modified in some way since the field was last populated. That is, the case reference is stale.

    This could be either a change to the data held in the case object, and/or a change in the object's internal version number.

    1. Re-read the case object.
    2. If necessary, examine the case data to check that no significant changes have occurred.
    3. Retry the Delete Case Object(s) operation.
    UnsafeToDeleteCaseError (UnsafeToDeleteCaseError) The case object is referenced by processes other than the one that is attempting to delete the case object, therefore it is unsafe to delete the object.

    (This error is catchable only if you have specified a single case reference, not an array of case references.)

    Do not delete the case object.
  2. (Optional) Modify any process that may need to do something if this case object is deleted:
    1. Add a case data signal event to the process, so that the process will be notified if the case object is deleted.
    2. Add suitable business logic to perform any actions that the process needs to take as a result of the case object being deleted.