The IOrganizationPartyManagementGET Apex interface provides extensibility for 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.
Transforms a legacy or external identifier into the canonical resource ID expected by the retrieve operation and adds it to the shared request context as { id }.
- Resolve a legacy customer key to a Contact ID - Map a partner-system identifier to { id } - Normalize identifiers from migrated systems - Translate an account-specific reference into the canonical ID
Allows legacy clients and external integrations to retrieve resources using familiar identifiers without changing the shared API contract.
Role-Based or Regional Access Control
applyCustomValidations
Applies authorization and data-governance rules before the query executes. Access can be evaluated using the caller’s role, region, business unit, channel, or other request context.
- Restrict access to customers outside the user’s assigned region - Permit only supervisors to retrieve high-value customer records - Block partner channels from accessing internal-only resources - Enforce business-unit data boundaries
Enforces data-governance policies and prevents unauthorized access to protected records.
Toggle or Add Validation Flags
configureDefaultValidations
Enables, disables, or extends built-in validation flags for retrieve requests according to organization-specific policies.
- Require record-existence validation - Enable stricter identifier validation - Disable checks that do not apply to trusted internal channels - Apply different validation policies by tenant or environment
Allows each organization to relax or tighten retrieval checks without modifying the shared implementation.
Add Custom Fields or Server-Side Filters
customiseGraphQLQuery
Modifies the GraphQL query before execution by adding custom fields, relationships, filters, or server-side constraints.
- Add organization-specific Contact fields - Include entitlement or customer-hierarchy data - Apply regional, tenant, or lifecycle-status filters - Request a reduced field set for mobile clients
Returns richer, client-specific data without changing the base schema or introducing additional API versions.
Response Enrichment
handlePostOperation
Processes the query result before it is returned to the client. It can add calculated values, derived fields, audit metadata, or information from related systems.
- Add a calculated customer health score - Include retrieval audit metadata - Flag preferred or high-risk customers - Add aggregated financial, service, or usage insights
Delivers derived fields and audit metadata while preserving the underlying API schema.
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.
Resolve an external ID to a Salesforce Contact ID.
1global class OrganizationGetTransformRequestExt implements comms_apex_ext.IOrganizationPartyManagementGET {2 global static Map<String, Object> transformRequest(Map<String, Object> context) {3 if (context == null) {4 return context;5 }678 Object idObj = context.get('id');9 if (!(idObj instanceof String)) {10 return context;11 }12 String idValue = (String) idObj;131415 // A 15- or 18-character value already looks like a Salesforce Id; leave it as-is.16 if (idValue.length() == 15 || idValue.length() == 18) {17 return context;18 }192021 // Otherwise treat it as an external key and resolve it to an Account Id.22 List<Account> accounts = [23 SELECT Id FROM Account WHERE External_Id__c = :idValue LIMIT 124 ];25 if (!accounts.isEmpty()) {26 context.put('id', accounts[0].Id);27 }28 return context;29 }30 // ... other hooks return null / empty map ...31}
configureDefaultValidations
This hook enables, disables, or modifies the built-in validation rules before they execute.
Add a custom flag consumed by applyCustomValidations.
1global class OrganizationGetConfigValidationsExt implements comms_apex_ext.IOrganizationPartyManagementGET {2 global static Map<String, Boolean> configureDefaultValidations(3 Map<String, Boolean> defaultValidationConfiguration,4 Map<String, Object> context5 ) {6 Map<String, Boolean> overrides = defaultValidationConfiguration != null7 ? defaultValidationConfiguration.clone()8 : new Map<String, Boolean>();9 overrides.put('segmentAccessCheck', true); // your own flag, read in applyCustomValidations10 return overrides;11 }12 // ... other hooks return null / empty map ...13}
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)
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.