The ITroubleTicketManagementGET Apex interface provides extensibility for TMF621 GET operations through Apex pre- and post-hooks and GraphQL query customization. Implementations can validate incoming requests, modify query structures, and refine the response to support business-specific retrieval rules while maintaining TMF-compliant behavior.
The configureDefaultValidations hook is not used for the Trouble Ticket Management API. If implemented, the method may be invoked, but its return values are ignored.
Note
Retrieval Lifecycle Use Cases and Hook Mapping
This table lists common use cases and the hooks required for the GET operation.
Use Case
Hook(s)
Description
Example Scenarios
Benefit
Role-Based Data Filtering
applyCustomValidations, handlePostOperation
Enforces access rules by validating user permissions before execution and filtering sensitive data after retrieval. Supports role-based visibility at field and record levels.
• Restrict access to VIP or high-value customer profiles• Hide sensitive fields (e.g., credit score) for frontline agents• Enforce region-based access boundaries
Strengthens data governance and ensures secure, compliant access to trouble tickets
Custom Field Enrichment
handlePostOperation
Adds calculated or derived fields to API responses without changing the base TMF schema, allowing customers to extend or modify as needed. Enables enrichment using internal business rules or external systems.
• Add customer health score• Flag “preferred customer” status• Include aggregated financial or usage insights
Delivers richer, more contextual responses while preserving TMF schema integrity
Dynamic Query Customization
customiseGraphQLQuery
Modifies GraphQL queries dynamically based on client or request context by adding fields, filters, or transformations.
• Mobile app requests only essential fields• Portal requires additional entitlement or hierarchy fields• Apply filters automatically for partner channels
Supports diverse client requirements using a single API and reduces need for API versioning
Business Rule Validation
applyCustomValidations
Applies business and eligibility rules before processing requests, stopping invalid operations early in the lifecycle.
• Ensure customer is “active” before retrieving services• Reject unauthorized or unverified channel requests• Enforce lifecycle or dependency checks
Provides strong business consistency and reduces downstream errors by blocking invalid requests early
CaseNumber to Id Resolution
transformRequest
Resolve 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 processing
Support external systems that use CaseNumber instead of Salesforce Id
transformRequest
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.
1public Map<String, Object> transformRequest(Map<String, Object> context) {2 if (context == null) {3 return context;4 }5 Object idObj = context.get('id');6 if (idObj == null || !(idObj instanceof String)) {7 return context;8 }9 String idValue = (String)idObj;10 // Check if the ID looks like a Salesforce ID (starts with 500, 00X, etc.)11 // If not, assume it's a CaseNumber and resolve it12 if (idValue.length() == 15 || idValue.length() == 18) {13 // Looks like a Salesforce ID, return context as-is14 return context;15 }16 // Query Case objects where CaseNumber matches the provided ID17 List<Case> cases = [18 SELECT Id, CaseNumber19 FROM Case20 WHERE CaseNumber = :idValue21 LIMIT 122 ];23 // If found, replace the ID in context with the Salesforce ID24 if (!cases.isEmpty() && cases[0].CaseNumber != null) {25 context.put('id', cases[0].Id);26 }27 return context;28}
applyCustomValidations
This hook validates custom business logic before retrieving trouble ticket data. 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)
1public Map<String, Object> applyCustomValidations(Map<String, Object> context) {2 // Input context:3 // {4 // api: 'TroubleTicketManagement',5 // version: '5.0',6 // id: '00001027',7 // userId: '005xx000001Sv5',8 // fields: ['Id', 'Subject', 'Status']9 // }1011 String troubleTicketId = (String) context.get('id');12 String userId = (String) context.get('userId');1314 Map<String, Object> validationResult = new Map<String, Object>();1516 try {17 // Check if user has access to this trouble ticket18 User currentUser = [SELECT Id, Profile.Name FROM User WHERE Id = :userId LIMIT 1];19 Case troubleTicket = [SELECT Id, Status, CaseNumber FROM Case WHERE CaseNumber = :troubleTicketId LIMIT 1];2021 if ('Customer Service Rep'.equals(currentUser.Profile.Name)) {22 // Validate that Customer Service Reps cannot access closed tickets23 if ('Closed'.equals(troubleTicket.Status)) {24 // FAIL: User does not have access to closed tickets25 validationResult.put('validationStatus', 'FAIL');26 validationResult.put('validationMessage', 'User does not have access to closed trouble tickets');27 validationResult.put('validationDetails', new Map<String, Object>{28 'denialReason' => 'STATUS_RESTRICTION',29 'userProfile' => 'Customer Service Rep',30 'ticketStatus' => troubleTicket.Status31 });32 } else {33 // PASS: User has access to non-closed tickets34 validationResult.put('validationStatus', 'PASS');35 validationResult.put('validationMessage', 'User has access to this trouble ticket');36 }37 } else {38 // PASS: Other profiles have unrestricted access39 validationResult.put('validationStatus', 'PASS');40 validationResult.put('validationMessage', 'User profile has unrestricted access');41 }42 } catch (Exception e) {43 // FAIL: Error during validation44 validationResult.put('validationStatus', 'FAIL');45 validationResult.put('validationMessage', 'Validation error: ' + e.getMessage());46 validationResult.put('validationDetails', new Map<String, Object>{47 'errorType' => e.getTypeName()48 });49 }5051 // Return validation result directly (not wrapped in 'result' key)52 return validationResult;53}
customiseGraphQLQuery
This hook modifies the GraphQL query before execution to add fields, filters, or transformations. Returns a map with a nodes key containing a list of QueryTransformationNode objects.
Query transformations provide the ability to enhance GraphQL queries by adding fields, applying filters, or modifying the sort order, while preserving the original query definition.
For the Customer Management API, use the uiapi.query.Account path to reference the primary Account field.