nerdexam
Salesforce

PDI · Question #178

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…

The correct answer is B. After record-triggered flow C. Apex trigger. To prevent deletion of 'Container__c' records unless their 'Status__c' is 'Decommissioned', a developer can use an after delete record-triggered flow or an Apex trigger to roll back the transaction by throwing an error.

Submitted by anna_se· Apr 18, 2026Logic and Process Automation

Question

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 ipicklist value for the Statu3__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

Options

  • AValidation rule
  • BAfter record-triggered flow
  • CApex trigger
  • DBefore record-triggered flow

How the community answered

(26 responses)
  • A
    8% (2)
  • B
    81% (21)
  • D
    12% (3)

Why each option

To prevent deletion of 'Container__c' records unless their 'Status__c' is 'Decommissioned', a developer can use an `after delete` record-triggered flow or an Apex trigger to roll back the transaction by throwing an error.

AValidation rule

A validation rule primarily fires during `insert` and `update` operations and cannot directly prevent the deletion of a record based on its field values.

BAfter record-triggered flowCorrect

An `after delete` record-triggered flow can be configured to evaluate the `Status__c` field of the records being deleted. If the status is not 'Decommissioned', the flow can explicitly throw an error or fault, which will cause the entire deletion transaction to roll back, thereby preventing the record from being deleted.

CApex triggerCorrect

An Apex trigger with a `before delete` event is highly effective for this requirement. The trigger can inspect the `Status__c` field of the records in `Trigger.old` and, if the condition is not met, use the `addError()` method on the SObject to prevent the deletion and provide a custom error message to the user.

DBefore record-triggered flow

While a `before delete` record-triggered flow can also prevent deletion by throwing an error, the specific correct answers (B and C) indicate that an `after delete` flow (leveraging transaction rollback on error) and an Apex trigger are the intended solutions for this enforcement.

Concept tested: Transaction rollback for delete prevention

Source: https://developer.salesforce.com/docs/latest/guide/sfdc_flow_guidance_record_triggered_after_delete.htm

Topics

#Record Deletion Logic#Salesforce Flow#Apex Triggers#Automation Execution Order

Community Discussion

No community discussion yet for this question.

Full PDI Practice