Deleting Case Objects by Case Identifier

Within a process, you can delete one one or more case objects whose case identifiers match the values that you supply.

Prerequisites

The process must already contain a data field containing either:

  • the case identifier value of the case object that you want to delete.
  • an array of case identifier values for a set of case objects that you want to delete.

The data field must be of the same type as the case identifier attribute in the case class.

Each case identifier value(s) must be a complete and exact match for the case object that is to be deleted. You cannot use partial matches or wildcard characters - these will result in a CaseNotFoundError runtime error.

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: The best practice is to not delete case objects as part of a normal operation. If you do delete case objects, the best practice is to only delete using a single case reference from within a service task in a process. 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 Global Data Operations.
  3. Select Create Case Object(s) or Delete Case Object(s) by Case Identifier.
  4. In the Case Class field, select the appropriate case class for the case object(s) that you want to delete.
  5. In the Operation field, select Delete Case Object(s) by Case Identifier.
  6. In the Where case identifier field, enter the name of the case identifier that you want to use to identify the case object(s).
  7. In the Equals value of field, enter the name of the local data field that contains the case identifier value(s) of the case object(s) to be deleted.

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) by Case Identifier operation.
    Error (Error Code) Description Possible solutions
    UserApplicationError (CaseNotFoundError) A case object specified in the Equals value of does not exist.
    UserApplicationError (DeleteWhileLinkedError) A case object specified in the Equals value of has one or more association links to other case objects.
    1. Delete the association links.
    2. Retry the Delete Case Object(s) by Case Identifier operation.
  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.