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 on Itinerary__c objects

  • 'ItineraryItems' - Controls triggers on ItineraryItem__c objects

  • 'ItineraryBookings' - Controls triggers on ItineraryBooking__c objects

  • 'Passengers' - Controls triggers on Passenger__c objects

  • 'PassengerItineraryUnitAssignments' - Controls triggers on PassengerItineraryUnitAssignment__c objects

  • 'ItineraryGroups' - Controls triggers on ItineraryGroup__c objects

  • 'ItineraryServices' - Controls triggers on ItineraryService__c objects

  • 'ItineraryContents' - Controls triggers on ItineraryContent__c objects

  • 'PaymentSchedules' - Controls triggers on PaymentSchedule__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

  1. Data Migrations: Temporarily disable triggers during bulk data imports to improve performance and avoid recursive trigger execution.

  2. Custom Integrations: Control trigger execution when syncing data with external systems.

  3. Bulk Operations: Disable triggers during mass updates to prevent unwanted automation.

  4. 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.