Galapagos - Patch 27 (21.30)
Trigger Control API for External Code (ST-1620)
This feature introduces a global utility class that allows customers to control Kaptio trigger behavior programmatically, using their custom code. This provides greater flexibility for bulk operations, data migrations, and custom integrations where trigger execution needs to be temporarily suspended to optimise performance.
Manual steps
No manual configuration is required to enable this feature. The TriggerControl
class is automatically available as a global class upon deploying the package.
Global Trigger Control API
New Global Class
TriggerControl - A global utility class that provides methods to enable/disable Kaptio triggers from external code.
Individual Trigger Control
-
TriggerControl.disableTrigger(String domainClassName)
- Disables a specific trigger for the given SObject domain class -
TriggerControl.enableTrigger(String domainClassName)
- Enables a previously disabled trigger for the given SObject domain class
Supported Domain Classes:
-
'Itineraries'
- Controls triggers onItinerary__c
objects -
'ItineraryItems'
- Controls triggers onItineraryItem__c
objects -
'ItineraryBookings'
- Controls triggers onItineraryBooking__c
objects -
'Passengers'
- Controls triggers onPassenger__c
objects -
'PassengerItineraryUnitAssignments'
- Controls triggers on PassengerItineraryUnitAssignment__c objects -
'ItineraryGroups'
- Controls triggers onItineraryGroup__c
objects -
'ItineraryServices'
- Controls triggers onItineraryService__c
objects -
'ItineraryContents'
- Controls triggers onItineraryContent__c
objects -
'PaymentSchedules'
- Controls triggers onPaymentSchedule__c
objects
Bulk Trigger Control
-
TriggerControl.disableAllKaptioTriggers()
- Disables all common Kaptio triggers in a single call -
TriggerControl.enableAllKaptioTriggers()
- Enables all common Kaptio triggers in a single call
How it works
Use Cases
-
Data Migrations: Temporarily disable triggers during bulk data imports to improve performance and avoid recursive trigger execution.
-
Custom Integrations: Control trigger execution when syncing data with external systems.
-
Bulk Operations: Disable triggers during mass updates to prevent unwanted automation.
-
Testing: Control trigger behavior in test classes for isolated unit testing.
Example Usage
// Disable all Kaptio triggers before bulk operation
TriggerControl.disableAllKaptioTriggers();
// Perform bulk DML operations
insert largeListOfItineraries;
update massItineraryItems;
// Re-enable all triggers after operation
TriggerControl.enableAllKaptioTriggers();
Important Considerations
-
Scope: Trigger state changes are only effective for the current execution context.
-
Transaction Boundary: Trigger states automatically reset after transaction completion.
-
Error Handling: Invalid domain class names are silently ignored (no exceptions thrown).
-
Permissions: Users need appropriate permissions to execute global classes.
-
Best Practice: Always re-enable triggers after completing operations to ensure normal system behavior.