IIndividualPartyManagementDELETE Apex Interface
The IIndividualPartyManagementDELETE interface provides extensibility for DELETE operations through Apex-based validations, mutation-payload adjustments, and post-operation processing. Users can enforce deletion policies, apply soft-delete or metadata logic, and customize final responses without impacting TMF-compliant delete behavior.
This interface supports the following hooks.
- transformRequest
- configureDefaultValidations
- applyCustomValidations
- customiseMutationPayload
- handlePostOperation
The customiseGraphQLQuery is not applicable to DELETE, which is a write operation, so there is no read query to customize. This hook is declared on the read interface (ICommsGET), not on ICommsDELETE. To customize the soft-delete mutation payload, use customiseMutationPayload.
This table lists common use cases and the hooks required for the DELETE operation.
| Use Case | Hook(s) | Description | Example Scenarios | Benefit |
|---|---|---|---|---|
| Supply the Soft-Delete Status Field | customiseMutationPayload | Adds the status field required to perform a soft delete. The hook can also include deletion metadata or additional organization-specific fields in the GraphQL mutation payload. | - Set status to Deleted or Inactive- Add a deletion timestamp - Record the ID of the user performing the deletion - Include custom fields or mutation snippets | Required to make the DELETE operation functional while preserving the record for auditing, recovery, and historical reporting. |
| Prevent Deletion Under Business Rules | applyCustomValidations | Evaluates custom business rules before the mutation is built. If a rule fails, the hook prevents deletion and returns an HTTP 422 response with a clear validation message. | - Prevent deletion of an active customer - Block deletion when dependent records exist - Restrict deletion to authorized roles - Protect records in locked lifecycle states | Stops invalid deletions early and provides clients with a clear, actionable explanation of the failure. |
| Resolve an External ID to a Contact ID | transformRequest | Converts a legacy or external identifier into the canonical Contact ID expected by the delete operation and stores it in the shared request context as { id }. | - Resolve a legacy customer key - Map a partner-system identifier to a Contact ID - Convert an account-specific reference into { id }- Normalize migrated identifiers | Allows existing clients and legacy integrations to use familiar identifiers without changing the core delete contract. |
| Add Custom Validation Flags | configureDefaultValidations | Enables, disables, or adds validation flags for the delete operation. This supports organization-specific policies, especially because DELETE does not register built-in validations by default. | - Require record-existence validation - Enable concurrency or version checks - Require confirmation for protected records - Apply stricter validation in regulated organizations | Supports per-organization deletion policies without modifying the shared delete implementation. |
| Audit or Cascade After Deletion | handlePostOperation | Runs after the delete mutation completes and receives the deleteResult summary. It can use that result to perform auditing, cascading updates, event publication, or other side effects. | - Write an audit record - Cascade the deleted status to dependent resources - Publish a deletion event - Invalidate related caches or search indexes - Record deletion metrics | Enables reliable post-delete processing using the mutation’s deleteResult summary while keeping side effects separate from the core operation. |
This hook transforms the request context before processing any operation. It is invoked early in the request lifecycle, allowing implementers to adjust the context for subsequent extensibility hooks.
Map<String, Object> transformRequest(Map<String, Object> context)
Resolve an external ID to a Salesforce Contact ID.
This hook enables, disables, or modifies the built-in validation rules before they execute.
Map<String, Boolean> configureDefaultValidations(Map<String, Boolean> defaultValidationConfiguration, Map<String, Object> context)
Add a custom flag consumed by applyCustomValidations.
This hook validates custom business logic before retrieving customer record. If validation fails, it rejects the request and returns an error response.
The handler processes return values as follows.
Success:
- Return a map with validationStatus set to “pass” (case-insensitive).
- The API request continues normally.
- Other fields in the map are logged but not used.
Failure:
- Return a map with validationStatus set to “fail” (case-insensitive).
- The API request is terminated immediately.
- Raise a ValidationException containing
- message: value from validationMessage key (or “Validation failed” by default)
- details: value from validationDetails key (optional)
- The client receives an HTTP 400 error response.
Map<String, Object> applyCustomValidations(Map<String, Object> context)
Prevent deletion when the Individual party has open order.
This hook modifies the mutation payload before deleting a customer record. Use this to add deletion metadata, set soft-delete flags, or apply business logic transformations.
Map<String, Object> customiseMutationPayload(Map<String, Object> request, Map<String, Object> context)
Supply the soft-delete status field.
This hook post-processes and transforms the API response after data retrieval.
Map<String, Object> handlePostOperation(Map<String, Object> graphQLQueryResultAsMap, Map<String, Object> constructedTMFResponse, Map<String, Object> context)
Audit the deletion.
Here’s a complete sample Apex implementation using all supported hooks.