Which two changes should a developer make in this trigger to adhere to best practices?

Consider the above trigger intended to assign the Account to the manager of the Account’s region.

trigger AssignOwnerByRegion on Account ( before insert, before update )

{

List<Account> accountList = new List<Account>();

for( Account anAccount : trigger.new )

{

Region__c theRegion = [

SELECT Id, Name, Region_Manager__c

FROM Region__c

WHERE Name = :anAccount.Region_Name__c

];

anAccount.OwnerId = theRegion.Region_Manager__c;

accountList.add( anAccount );

}

update accountList;

}

Which two changes should a developer make in this trigger to adhere to best practices? (Choose two.)
A . Use a Map to cache the results of the Region__c query by Id.
B . Move the Region__c query to outside the loop.
C . Remove the last line updating accountList as it is not needed.
D . Use a Map accountMap instead of List accountList.

Answer: AD

Latest PDII Dumps Valid Version with 280 Q&As

Latest And Valid Q&A | Instant Download | Once Fail, Full Refund

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments