The ICustomerManagementGET Apex interface provides extensibility for TMF629 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 Customer 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 customer data
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
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 }56 Object idObj = context.get('id');7 if (idObj == null || !(idObj instanceof String)) {8 return context;9 }1011 String idValue = (String)idObj;1213 // Check if the ID looks like a Salesforce ID (starts with 001, 003, etc.)14 // If not, assume it's an AccountNumber and resolve it15 if (idValue.length() == 15 || idValue.length() == 18) {16 // Looks like a Salesforce ID, return context as-is17 return context;18 }1920 // Query Account objects where AccountNumber matches the provided ID21 List<Account> accounts = [22 SELECT Id, AccountNumber23 FROM Account24 WHERE AccountNumber = :idValue25 LIMIT 126 ];2728 // If found, replace the ID in context with the Salesforce ID29 if (!accounts.isEmpty() && accounts[0].AccountNumber != null) {30 context.put('id', accounts[0].Id);31 }3233 return context;34 }
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)
1public Map<String, Object> applyCustomValidations(Map<String, Object> context) {2 // Input context:3 // {4 // api: 'CustomerManagement',5 // version: '4.0',6 // customerId: '001xx000003DHP',7 // userId: '005xx000001Sv5',8 // requiredFields: ['Id', 'Name']9 // }1011 String customerId = (String) context.get('customerId');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 customer18 User currentUser = [SELECT Id, Profile.Name FROM User WHERE Id = :userId LIMIT 1];19 Account customer = [SELECT Id, BillingCountry FROM Account WHERE Id = :customerId LIMIT 1];2021 if ('Customer Service Rep'.equals(currentUser.Profile.Name)) {22 // Validate customer is in allowed region23 if ('US'.equals(customer.BillingCountry)) {24 // PASS: User has access25 validationResult.put('validationStatus', 'PASS');26 validationResult.put('validationMessage', 'User has access to this customer');27 } else {28 // FAIL: User does not have access to this region29 validationResult.put('validationStatus', 'FAIL');30 validationResult.put('validationMessage', 'User does not have access to customers in this region');31 validationResult.put('validationDetails', new Map<String, Object>{32 'denialReason' => 'REGION_RESTRICTION',33 'userRegion' => 'US',34 'customerRegion' => customer.BillingCountry35 });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 spec 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.