TRG_ExecuteValidationRules
Class · Group: Validation
global inherited sharing class TRG_ExecuteValidationRules extends TRG_Base implements IF_Trigger.BeforeInsert, IF_Trigger.AfterInsert, IF_Trigger.BeforeUpdate, IF_Trigger.AfterUpdate, IF_Trigger.BeforeDelete, IF_Trigger.AfterDelete, IF_Trigger.AfterUndeleteExtends: TRG_Base
Implements: IF_Trigger.BeforeInsert, IF_Trigger.AfterInsert, IF_Trigger.BeforeUpdate, IF_Trigger.AfterUpdate, IF_Trigger.BeforeDelete, IF_Trigger.AfterDelete, IF_Trigger.AfterUndelete
Known Derived Types: IF_Trigger.AfterDelete.afterDelete(List<SObject>), IF_Trigger.AfterInsert.afterInsert(List<SObject>), IF_Trigger.AfterUndelete.afterUndelete(List<SObject>), IF_Trigger.AfterUpdate.afterUpdate(List<SObject>,List<SObject>), IF_Trigger.BeforeDelete.beforeDelete(List<SObject>), IF_Trigger.BeforeInsert.beforeInsert(List<SObject>), IF_Trigger.BeforeUpdate.beforeUpdate(List<SObject>,List<SObject>)
Pre-built trigger action that executes formula-driven validation rules. This class implements all trigger interfaces and automatically executes validation rules configured via ValidationRuleGroup__mdt and ValidationRule__mdt for the current trigger context. Subscriber Org Setup: Create TriggerSetting__mdt for your object (if not already exists) Create TriggerAction__mdt pointing to kern.TRG_ExecuteValidationRules Configure ValidationRuleGroup__mdt linked to your TriggerSetting Create ValidationRule__mdt records with formulas and error messages
Since: 1.0
Example:
// TriggerAction__mdt configuration (no code required)
DeveloperName: Execute_Account_Validation_Rules
MasterLabel: Execute Account Validation Rules
ApexClassName__c: kern.TRG_ExecuteValidationRules
TriggerSetting__c: Account_Trigger_Setting
Event__c: Before Insert
Order__c: 10
Description__c: Executes formula-driven validation rules for Account recordsSee Also: UTIL_ValidationRule, ValidationRuleGroup__mdt, ValidationRule__mdt
Methods
| Method | Description |
|---|---|
| global void afterDelete(List<SObject> oldRecords) | Executes validation rules after records are deleted. |
| global void afterInsert(List<SObject> newRecords) | Executes validation rules after new records are inserted. |
| global void afterUndelete(List<SObject> newRecords) | Executes validation rules after records are undeleted. |
| global void afterUpdate(List<List<SObject> oldRecords) | Executes validation rules after records are updated. |
| global void beforeDelete(List<SObject> oldRecords) | Executes validation rules before records are deleted. |
| global void beforeInsert(List<SObject> newRecords) | Executes validation rules before new records are inserted. |
| global void beforeUpdate(List<List<SObject> oldRecords) | Executes validation rules before records are updated. |
Method Details
afterDelete
global void afterDelete(List<SObject> oldRecords)Executes validation rules after records are deleted. Typically used for warning-only validations that log but don't block.
Parameters:
oldRecords(List) - The list of deleted records
Since: 1.0
Example:
instance.afterDelete(records);afterInsert
global void afterInsert(List<SObject> newRecords)Executes validation rules after new records are inserted. Typically used for warning-only validations that log but don't block.
Parameters:
newRecords(List) - The list of newly inserted records
Since: 1.0
Example:
instance.afterInsert(records);afterUndelete
global void afterUndelete(List<SObject> newRecords)Executes validation rules after records are undeleted. Typically used for warning-only validations that log but don't block.
Parameters:
newRecords(List) - The list of undeleted records
Since: 1.0
Example:
instance.afterUndelete(records);afterUpdate
global void afterUpdate(List<SObject> newRecords, List<SObject> oldRecords)Executes validation rules after records are updated. Typically used for warning-only validations that log but don't block.
Parameters:
newRecords(List) - The list of records with new valuesoldRecords(SObject) - The list of records with old values
Since: 1.0
Example:
instance.afterUpdate(records, records);beforeDelete
global void beforeDelete(List<SObject> oldRecords)Executes validation rules before records are deleted.
Parameters:
oldRecords(List) - The list of records to be deleted
Since: 1.0
Example:
instance.beforeDelete(records);beforeInsert
global void beforeInsert(List<SObject> newRecords)Executes validation rules before new records are inserted.
Parameters:
newRecords(List) - The list of new records to validate
Since: 1.0
Example:
instance.beforeInsert(records);beforeUpdate
global void beforeUpdate(List<SObject> newRecords, List<SObject> oldRecords)Executes validation rules before records are updated.
Parameters:
newRecords(List) - The list of records with new valuesoldRecords(SObject) - The list of records with old values
Since: 1.0
Example:
instance.beforeUpdate(records, records);