ITroubleTicketManagementPATCH Apex Interface

The ITroubleTicketManagementPATCH interface supports extensibility for PATCH operations by allowing validation, transformation, and post-processing of update requests. Implementations can enforce business rules, adjust mutation payloads, and refine the resulting responses maintaining TMF-compliant behavior.

This interface supports the following hooks.

Following hook is not used for the Trouble Ticket Management API. If implemented, the method may be invoked, but its return values are ignored.

  • configureDefaultValidations

The following table lists common use cases and hooks required for PATCH operation.

Use CaseHook(s)Description
Example Scenarios
Benefit
Enforce Status TransitionsapplyCustomValidationsValidates requested status changes before updating the record to ensure transitions adhere to defined lifecycle rules, regulatory constraints, or business policies. Stops invalid or unauthorized state changes.• Prevent transition from InactiveActive without required approvals• Block changes to Suspended unless preconditions are met• Enforce linear lifecycle progression (e.g., PendingActive, but not ClosedActive)Prevents invalid or noncompliant state transitions and preserves data integrity
Automatic Field PopulationcustomiseMutationPayloadAutomatically populate fields like Reason or Origin during updates.• Add Reason and Origin fields• Track system-initiated vs. user-initiated changesProvides a complete and reliable audit trail for internal governance and external compliance needs
Validate Data FormatapplyCustomValidationsEnsures updated data—such as contact details, identifiers, or structured fields—meets required formatting rules before the update is processed. Prevents malformed or inconsistent data from entering the system.• Validate phone number format• Confirm email structure and domain correctness• Ensure address fields follow standardized formatsEnsures required fields are always set without requiring client to provide them
Response EnrichmenthandlePostOperationAutomatically enriches the update payload with audit metadata before persistence. Ensures all modifications are traceable and compliant with auditing standards.• Add “modifiedBy” and timestamp fields• Track system-initiated vs. user-initiated changes• Add audit IDs for downstream monitoring systemsProvides a complete and reliable audit trail for internal governance and external compliance needs
CaseNumber to Id ResolutiontransformRequestResolve CaseNumber identifiers to Salesforce Ids for API compatibility.• An external system sends a CaseNumber (e.g., 00001027), which is resolved to a Salesforce record ID for API processingSupport external systems that use CaseNumber instead of Salesforce Id

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)

This hook validates custom business logic before updating a customer data. If validation fails, rejects the request and returns an error response.

The handler processes return values as follows.

Success:

  • Return a map with validationStatus set to any value other than “fail” (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)

This hook modifies the mutation payload before updating a customer record. Use this to add computed fields, transform values, or apply business logic transformations.

Map<String, Object> customiseMutationPayload(Map<String, Object> request, Map<String, Object> context)

For Trouble Ticket Management API, use path troubleTicket to target the main Case mutation

This hook modifies the GraphQL query before execution to add fields, filters, or transformations. Returns a map with a spec key containing a list of QueryTransformationNode objects.

Map<String, Object> customiseGraphQLQuery(Map<String, Object> graphQLAsMap, Map<String, Object> context)

This hook post-processes and transforms the API response after data is updated.

Map<String, Object> handlePostOperation(Map<String, Object> graphQLQueryResultAsMap, Map<String, Object> constructedTMFResponse, Map<String, Object> context)

Here’s a complete sample Apex implementation using all supported hooks.

Successful PATCH Response

Update mutations modify existing records and return the updated records with the specified output fields.

Original Mutation (GraphQL):

Transformation Instructions (JSON):

Result (GraphQL):

Original Mutation (GraphQL):

Transformation Instructions (JSON - Add Input Fields):

Result (GraphQL):

Transformation Instructions (JSON):

Result (GraphQL):