A developer uses a before insert trigger on the Lead object to fetch the Territory__c object, where the Territory__c.PostalCode__c matches the Lead.PostalCode. The code fails when the developer uses the Apex Data Loader to insert 10,000 Lead records. The developer has the following code block: Line-01: for (Lead l : Trigger.new){Line-02: if (l.PostalCode != null) {Line-03: List<Territory__c> terrList = [SELECT Id FROM Territory__c WHERE PostalCode__c = :l.PostalCode];Line-04: if(terrList.size() > 0) Line-05: l.Territory__c = terrList[0].Id; Line-06: }Line-07: }Which line of code is causing the code block to fail?
Suggested Answer: A
Get Premium DEX-450 Questions
as Interactive Web-Based Practice Test or PDF
Real Exam Format
Detailed Explanations
Instant Access
Get Your Practice Test
11 comments · newest first
MO
Mozell
12 months ago
Really? I thought you could update it in triggers.
PA
Pamella
12 months ago
Line-05 is also a problem, you can't modify Lead in a before insert.
NE
Nettie
12 months ago
Wait, can’t you just bulkify it? Seems like a simple fix.
HY
Hyun
1 year ago
I agree, that will hit governor limits fast!
SO
Sommer
1 year ago
Line-03 is definitely the issue, SOQL in a loop is a no-go.
RO
Rory
1 year ago
I recall something about not being able to update the Lead in a before insert trigger, which makes me think Line-05 could be the culprit.
TU
Tula
1 year ago
I think Line-02 could cause a NullPointer exception if PostalCode is null, but I'm not completely confident about that.
SH
Shaquana
1 year ago
I'm not entirely sure, but I thought we learned that Trigger.new is valid in before insert triggers, so Line-01 might not be the issue.
MO
Monroe
1 year ago
I remember we discussed how placing a SOQL query inside a loop can lead to governor limit issues, so I think Line-03 is the problem.
JU
Junita
1 year ago
Option A seems like the obvious choice here. The whole point of cryptocurrency is that it's a decentralized digital currency, and that's made possible by the blockchain technology that acts as an immutable ledger. The other options don't really capture the core technical innovation behind crypto.
MA
Marvel
1 year ago
Hmm, I'm a little unsure about this one. I know MACRS is an accelerated depreciation method, but I can't quite recall how that impacts the total depreciation compared to straight-line. I'll need to review my notes on this topic before answering.