Skip to content

Instantly share code, notes, and snippets.

@tauno
Created August 26, 2016 17:02
Show Gist options
  • Save tauno/40ed6e4fbe1c286f98aebf7876bad935 to your computer and use it in GitHub Desktop.
Save tauno/40ed6e4fbe1c286f98aebf7876bad935 to your computer and use it in GitHub Desktop.
Simple merge log Trigger for Salesforce Contacts
trigger ContactMergeTrigger on Contact (after delete) {
List<Merged_Contact__c> listMergedContacts = new List<Merged_Contact__c>();
for(Contact contact : trigger.old) {
if(String.isNotBlank(contact.MasterRecordId)) {
listMergedContacts.add(new Merged_Contact__c(Contact__c = contact.MasterRecordId, Old_Contact__c = contact.id));
}
}
if(listMergedContacts.size() > 0) {
insert listMergedContacts;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment