PDI · Question #96
Universal Container wants Opportunities to no longer be editable when itreaches the Closed/Won stage. Which two strategies can a developer use to accomplish this? Choose2 answer
The correct answer is A. Use a validation B. Use a trigger. The objective is to prevent Opportunity records from being edited once they reach the 'Closed/Won' stage.
Question
Universal Container wants Opportunities to no longer be editable when itreaches the Closed/Won stage. Which two strategies can a developer use to accomplish this? Choose2 answer
Options
- AUse a validation
- BUse a trigger
- CUse an after-save flow.
- DUse the Process Automation settings.
How the community answered
(26 responses)- A77% (20)
- C8% (2)
- D15% (4)
Why each option
The objective is to prevent Opportunity records from being edited once they reach the 'Closed/Won' stage.
A validation rule can be configured to prevent saving an Opportunity if its StageName is 'Closed/Won' and any field is modified, effectively making the record uneditable.
An Apex trigger (specifically a 'before update' trigger) can inspect changes to the Opportunity when its StageName is 'Closed/Won' and add an error to the record, preventing the update operation.
An after-save flow runs after the record has been saved, so it cannot prevent the initial save operation or roll back changes; thus, it cannot prevent an edit from occurring.
Process Automation settings is a broad term; while some tools within it (like Process Builder or Flow) can trigger logic, they cannot directly prevent a record save in the same way a validation rule or 'before' trigger can.
Concept tested: Preventing record edits with validation rules and triggers
Source: https://help.salesforce.com/s/articleView?id=sf.validation_rules.htm&type=5
Topics
Community Discussion
No community discussion yet for this question.