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
NadiaNadia 

account merging

Hi, I am trying to merge two accoutns using apex when a new account that is created matches  an existing master account by name. In after insert trigger, I call merge DML statement:  merge primaryAcc newAcc; given their names match.
When I test it, I see that a merge operation is being called and that a newly created account gets deleted after that, however  if I add some fields to a new account, I dont see them being copied to a master account during merge.
If I try to merge using 'Merge Accounts' tools from SF interface, it works fine and the fields are getting updated, but I can't get it to work with APEX. Can anyone help?
thanks!
TehNrdTehNrd
Looking over the documentation I do not believe any fields are carried over. It merely deletes the non master account (new) and re-parents any child options. Yet a new Account is not going to have any child objects, unless perhaps it is a lead conversion, so I'm not seeing how this would help you.

-Jason
NadiaNadia
thanks for reply. So are you saying that all what merge does is deletes the new account and reparents children, which are not even usually there? It seems to me that the task of merge should be to merge the fields. But I agree that documentation does not tell any details, unfortnately.
TehNrdTehNrd
That is the way I am interpreting it. There is no way for the code to know which fields to merge (overwrite).