When you merge two records in salesforce then salesforce doesn't fire any callbacks(trigger) on winning record(winning/master record) because its system update but you still want to do update some columns on master record when its get merged.
To achieve this you can use MasterRecordId which is available onwards salesforce api version 46.
Lets understand this with an example:
- Assume you have Account A and B, Account A is going to be merged to account B so account B will become the winning/master record.
- Let say you want update the Name of account B which is wining/master record.
- So you can write trigger on Account as below:
trigger accountMergeUpdateWinner on Account (after update) {
List<Account> acctListToBeUpdated = new List<Account>();
for(Account acct : Trigger.old) {
if(acct.MasterRecordId != Null){
Id winnerId = acct.MasterRecordId;
Account acctWinnerRecord = [SELECT Id, Name FROM Account WHERE Id =: winnerId];
acctWinnerRecord.Name = 'Update Name';
acctListToBeUpdated.add(acctWinnerRecord)
}
}
update acctListToBeUpdated;
}
This is how you can update the winning records :)
Read the below if you want to call salesforce custom Api
Salesforce get access token - Bearer token - (to make Salesforce REST API call via Postman )