An Apex trigger creates an Order__c record every time an Opportunity is won by a Sales Rep. Recently the trigger is creating two orders. What is the optimal method for a developer to troubleshoot this?
A.
Set up debug logging for every Sales Rep, then monitor the logs for errors and exceptions.
B.
Turn off all Workflow Rules, then turn them on one at time to see which one causes the error.
C.
Add system.debug() statements to the code and use the Developer Console logs to trace the code.
D.
Run the Apex Test Classes for the Apex trigger to ensure the code still has sufficient code coverage.
I choose C, because the debug logs can catch the below issues:
Trigger recursion: If an Order__c record creation causes another update on Opportunity, which re-fires the trigger, causing another Order__c record.
Automation Conflicts: The trigger might be running twice due to a combination of Workflow Rules, Process Builder, or other automation.
Duplicate Trigger Logic: The trigger might lack a check to prevent multiple insertions.
It's not A, due to this being inefficient because not all Sales Reps will trigger the issue every time. You'll be digging through logs for hours. Since the records insert correctly, there may not be any errors.
Answer is C. You probably won't receive any error or exception since the two workorders are inserted correctly. Probably a recursion error made by the opportunity update. It's best to add system.debug and check what is going on...
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
BrainMelt12
1 month, 1 week agocorpex
7 months, 2 weeks agoKyrgyzBoy
1 year, 5 months agoDylluan
12 months ago