To enforce that only Container__c records with a status of "Decommissioned" can be deleted, we need to prevent deletion of records unless they meet this criteria.
Possible Approaches:
Option A: Apex Trigger
Correct.
Explanation:
An Apex before delete trigger can be written to check the Status__c field of each record being deleted.
If the status is not "Decommissioned," the trigger can add an error to prevent deletion.
trigger PreventContainerDeletion on Container__c (before delete) {
for (Container__c container : Trigger.old) {
if (container.Status__c != 'Decommissioned') {
container.addError('Only decommissioned containers can be deleted.');
}
}
}
[Reference:, Apex Triggers, Option D: Before Record-Triggered Flow, Correct., Explanation:, A before delete flow can be created to check the Status__c field., If the status is not "Decommissioned," the flow can prevent deletion by adding an error., Reference:, Record-Triggered Flows, Add an Error to Stop a Record from Being Deleted, Incorrect Options:, Option B: Validation Rule, Incorrect., Explanation:, Validation rules fire on insert and update operations, not on delete., They cannot prevent deletion of records., Reference:, Validation Rule Considerations, Option C: After Record-Triggered Flow, Incorrect., Explanation:, After delete flows cannot prevent a deletion because the record has already been deleted., Only before delete flows can prevent deletion., Reference:, Flow Trigger Order, Conclusion:, To enforce the deletion restriction, the developer can use an Apex trigger or a before delete record-triggered flow, which are options A and D., ]