Preparing Practice Exam…
Please wait a moment while the system generates the exam questions, answers, and study session.
Please wait a moment while the system generates the exam questions, answers, and study session.
Salesforce Certified Platform Developer II (PDII) · Salesforce
Select 2 answers.
This question asks for 2 answers, but our data marks only 1. Compare with the community discussion below for the full answer.
Written by other learners. Comments can disagree with the marked answer — check the official documentation when in doubt.
B and C correct as per best parctices
B) Performing Queries inside a loop is not good practice, C) Changes made to records retrieved from 'Before' trigger context are automatically persisted if the trigger transaction completes successfully
B&C is correct if we're only talking about best practices. But we still need to tidy it up a bit like code below. trigger AssignOwnerByRegion on Account ( before insert, before update ) { Set<String> acctRegionNames = new Set<String>(); for( Account acc : Trigger.new){ acctRegionNames.add(acc.Region_Name__c); } Map<String, String> regionMap = new Map<String, String>(); for( Region__c reg : [SELECT Name, Region_Manager__c FROM Region__c Name IN :acctRegionNames]){ regionMap.put(reg.Name, reg.Region_Manager__c); } for( Account anAccount : trigger.new ){ if(regionMap.containsKey(anAccount.Name)){ anAccount.OwnerId = regionMap.get(anAccount.Name); } } }