So the Apex docs say you have to set the value of the master record if you want to retain the discarded account field values before the merge
operation.
Is there a better way to do validation for a merge
DML Operation then having to write tons if
statements for each field to validate if a field is null
on a master record before setting it to the retained value of the discarded account?
Example:
public void mergeAccountFields(Account masterRecord, Account discardedAccount){
if(masterRecord.FirstName __c == null){
masterRecord.FirstName__c = discardedAccount.FirstName__c;
}
if(masterRecord.LastName__c == null){
masterRecord.LastName__c = discardedAccount.LastName__c;
}
if(masterRecord.NumberOfLocations__c == null){
masterRecord.NumberOfLocations__c = discardedAccount.NumberOfLocations__c;
}
}