fferpcore.PluggableTriggerApiglobal with sharing class PluggableTriggerApi Provides interfaces that can be used to create plugins to be executed during the trigger of objects shared between multiple packages. Unlike creating multiple triggers, multiple plugins will be called in a defined order. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. global class BillingDocumentTriggerPluginConstructor implements fferpcore.PluggableTriggerApi.PluginConstructor { global Schema.SObjectType sObjectType() { //This plugin will only be used for Billing Documents. return fferpcore__BillingDocument__c.SObjectType; } global PluggableTriggerApi.Plugin construct(List<SObject> objects, PluggableTriggerApi.Context triggerContext) { return new BillingDocumentTriggerPlugin(objects); } } /** * An example plugin class that would block billing documents from being deleted. */ global class BillingDocumentTriggerPlugin implements fferpcore.PluggableTriggerApi.Plugin { private final List<SObject> m_records; public BillingDocumentTriggerPlugin(List<SObject> records) { m_records = records; } global void onBeforeInsert() {} global void onBeforeUpdate(Map<Id,SObject> existingRecords) {} global void onBeforeDelete() {} global void onAfterInsert() {} global void onAfterUpdate(Map<Id,SObject> existingRecords) {} global void onAfterDelete() { for (SObject record : m_records) { record.addError('Cannot delete billing documents'); } } global void onAfterUndelete() {} } fferpcore.PluggableTriggerApi.Pluginglobal interface Plugin Interface that plugins should implement. The objects being processed by the trigger should be stored on instances implementing this interface. Methods
onBeforeInsertvoid onBeforeInsert() Override this to perform processing during the before insert phase. onBeforeUpdatevoid onBeforeUpdate(Map<Id, SObject> existingRecords) Override this to perform processing during the before update phase. Input Parameters
onBeforeDeletevoid onBeforeDelete() Override this to perform processing during the before delete phase. onAfterInsertvoid onAfterInsert() Override this to perform processing during the after insert phase. onAfterUpdatevoid onAfterUpdate(Map<Id, SObject> existingRecords) Override this to perform processing during the after update phase. Input Parameters
onAfterDeletevoid onAfterDelete() Override this to perform processing during the after delete phase. onAfterUndeletevoid onAfterUndelete() Override this to perform processing during the after undelete phase. fferpcore.PluggableTriggerApi.PluginConstructorglobal interface PluginConstructor Constructs a plugin during a particular trigger execution. This is responsible for deciding whether a plugin is appropriate to the current trigger, and passing trigger context to the plugin being created. Methods
sObjectTypeSchema.SObjectType sObjectType() Used to select only plugins that are relevant to the records in the trigger. Return ValueThe sobject type that this plugin should be applied to. constructPluggableTriggerApi.Plugin construct(List<SObject> objects, fferpcore.PluggableTriggerApi.Context triggerContext) Called at the start of the trigger execution to construct plugins that will be applied. Input Parameters
Return ValueA plugin that will operate on the given sobjects when called. fferpcore.PluggableTriggerApi.Contextglobal virtual with sharing class Context Additional information regarding the trigger context that the plugin is being called in. Currently unused, but in place for later expansion. |