Please let me know if this should be deleted and/or merged with other topics (but literally every single google result I get is purple already - I have looked at everything I can find).

Long story very short, I need to update a merged record field (on the winner of the merge) to fire a flow. I have looked at after delete triggers for the losing record of the merge, but I don't think this is the way (please please correct if I'm wrong). I think I need to do an after update trigger on the winning record instead to update the winning record's field, that will then fire the flow.

I have an after delete trigger looking at losing records where MasterRecordID != null, but I'm having trouble updating the winning record (foreign key errors). I am open to any other suggestions if this sounds like a bad approach. Any help would be much appreciated.



trigger contactMergeUpdateWinner on Contact (after delete) {

for(Contact cont : Trigger.old){
    if(cont.MasterRecordId != Null){
        String winnerId = cont.MasterRecordId;
        Contact contWinner = [SELECT Id, Launch_Flow__c FROM Contact WHERE Id =: winnerId];
        contWinner.Launch_Flow__c = true;
        update contWinner;


I am receiving "currently in a merge operation, therefore a trigger can not update it".

I know there is probably a super simple explanation for this. I'm googling everything I can, so I'm sure I'll come across the answer soon, but any help is much appreciated.

  • We'll need to see your implementation and the errors you hit to better assist.
    – Adrian Larson
    Feb 10, 2021 at 18:03
  • @AdrianLarson Hi Adrian, thanks for your response. I've edited my post to include the trigger, and the error
    – david5712
    Feb 12, 2021 at 14:54
  • @AdrianLarson So I'm reading that after triggers do not update fields is that accurate? The requirement is very simple - when a merge happens, update a field on the winning record. That's it, that's all I want to do.
    – david5712
    Feb 12, 2021 at 15:53

1 Answer 1


This is how you can do it from a Future method:


trigger AccountTrigger on Account(after delete)
    Map<id,String> WinningmasterRec = new Map<id,String>();
    for(Account acc :Trigger.old){
               WinningmasterRec.put(acc.MasterRecordId, acc.Account_External_Id__c);
    if(WinningmasterRec!=null && (!WinningmasterRec.isEmpty())){

future Class:

public class AccountDuplicateMerge
    Public static void accountMerge(Map<id, String> winningoldMap){
        List<Account> accList = new List<Account>();
        for(id Win: winningoldMap.keySet()){
            Account acc = new Account(id = Win, External_Record_ID__c = winningoldMap.get(Win));  
        if(accList!= null && (!accList.isEmpty())){
            update accList;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .