function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Dhananjay Patil 12Dhananjay Patil 12 

How to Bypass Merge Operation for the specific scenario

Hello Guys,
I have a requirement inwhich system will allow to delete an account only when its related contacts status are inactive...if any of the contacts are active then it should throw an error message..I have fulfilled this functionality by writing apex code on beforedelete event..My code is working fine but there is a standard functionlity in salesforce called as "Merging"........In that scenario when i merge two accounts,if loosing account contains  active records then it is throwing me validation message...but I have to bypass my code when it comes to the merging....

Can anybody suggest me,how I bypass the code? 

One thing I tried,note down the masterid of winning record and put in my condition where I can bypass the scenario..but when I merge the accounts then I am not able to get MasterID of Winiing record....I am not sure why this is happening??? 
Ideally I should get some ID of the merge operation.......