Salesforce Certified Platform Developer II — Question 170

A developer is working with existing functionality that tracks how many times a stage has changed for an Opportunity. When the Opportunity's stage is changed, a workflow rule is fired to increase the value of a field by one. The developer wrote an after trigger to create a child record when the field changes from 4 to 5.

A user changes the stage of an Opportunity and manually sets the count field to 4. The count field updates to 5, but the child record is not created.

What is the reason this is happening?

Answer options

Correct answer: D

Explanation

The correct answer is D because Trigger.old holds the state of the records before the update occurs, and since the count field was manually set to 4, Trigger.old would not register the increment to 5. The other options are incorrect; after triggers do execute after workflows, Trigger.new does change after a field update, and after triggers are indeed fired after field updates.