Valid PDI Dumps shared by ExamDiscuss.com for Helping Passing PDI Exam! ExamDiscuss.com now offer the newest PDI exam dumps, the ExamDiscuss.com PDI exam questions have been updated and answers have been corrected get the newest ExamDiscuss.com PDI dumps with Test Engine here:
Managers at Universal Containers want to ensure that only decommissioned containers are able to be deleted in the system. To meet the business requirement a Salesforce developer adds "Decommissioned" as a picklist value for the status__c custom field within the Container__c object. Which two approaches could a developer use to enforce only Container records with a status of "Decommissioned" can be deleted? Choose 2 answers
Correct Answer: A,D
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. 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.'); } } } 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. Validation rules fire on insert and update operations, not on delete. They cannot prevent deletion of records. After delete flows cannot prevent a deletion because the record has already been deleted. Only before delete flows can prevent deletion. Reference: Apex Triggers Option D: Before Record-Triggered Flow Correct. Record-Triggered Flows Add an Error to Stop a Record from Being Deleted Incorrect Options: Option B: Validation Rule Incorrect. Validation Rule Considerations Option C: After Record-Triggered Flow Incorrect. 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.