Salesforce Certified Platform Developer II — Question 106

What is a potential design issue with the following code?
trigger accountTrigger on Account (before update){ Boolean processOpportunity = false; List<opportunity> opptysClosedLost = new List<opportunity>() List<opportunity> IstAllOpp = [select StageName from Opportunity where accountId IN :Trigger.newMap.keySet()]; if(!IstAllOpp.isEmpty()) processOpportunity = true; while(processOpportunity)
{ for(opportunity o : IstAllOpp) if(o.StageName == 'Closed - Lost') opptysClosedLost.add(o); processOpportunity = false; if(!opptysClosedLost.isEmpty()) delete opptysClosedLost;

Answer options

Correct answer: D

Explanation

The correct answer is D because the while loop combined with the inner for loop can lead to excessive CPU time usage, potentially exceeding the Apex CPU time limit. Options A, B, and C are incorrect as they do not accurately reflect the primary issue of CPU time limits in this scenario.