Merge Accounts and Contact in Lightning like Classic

Hey there! 🙂

In today’s article, we shall discuss a quick and simple hack which will help us Merge Accounts and Contacts in Lightning just like we used to do in Classic.

Why the need for this hack?

Well, the merging of records works a bit in Lightning than Classic. In Lighnting, the merging of records is based on duplicacy. So if two records are duplicate(according to ‘Potential Duplicates’ LEX component), then you will be able to merge them using Potential Duplicates component. In classic, this is not the case and you can merge two records even if they do not qualify as duplicates. To know more, refer this links:

Merge Accounts: https://help.salesforce.com/articleView?id=account_merge.htm&type=5
Merge Contacts: https://help.salesforce.com/articleView?id=contacts_merge.htm&type=5

Having understood the difference, let’s see how we can use the Classic merge functionality in Lightning.

Idea

The solution to our problem is URL hack. The idea is to create 2 buttons, one for Contacts & one for Accounts.

Let’s roll!

For Account merge: Create a custom URL button of List type with the following URL:

 /merge/accmergewizard.jsp?retURL=/001 

Now add this button to the List View (Setup -> Object Manager -> Account -> Search Layout -> List View).

For Contact Merge: Create a custom URL button of List type with the following URL:

 /merge/conmergewizard.jsp?id={!Account.Id}&retURL=/{!Account.Id}

Now add this button to the Contact related list on Account Page layout.

How it looks!

Small catch!

While merging contacts, the Contact related list component doesn’t get refreshed. So the user will have to manually refresh the page.

[Update Winter 21]

Post Winter ’21 if are getting “… refused to connect” error, then try setting the ‘Behavior’ of the list button to:
Display in existing window without sidebar or header

This should fix it for you(worked for some at least)!

Thank you for being an awesome reader! Subscribe to this blog for receiving all the latest updates straight to your inbox. 🙂

65 thoughts on “Merge Accounts and Contact in Lightning like Classic

  1. This is great thank you! Is there a way to hide the button from non admins without creating a VF page? They don’t have rights to merge but it would be better if they cannot see the button at all. Thanks

    Like

    • That’s a really good point. Right now what I can think is maybe using custom permissions you can conditionally redirect user to some url. Am not sure if we can access custom permissions in URL formulae, but worth a try.

      Like

  2. I had that thought, too, but then realized if I look the All Account list view, the new button is visible only in the drop-down menu next to the three buttons I’ve got visible on that page layout; if I look at the Recently Viewed list view, it’s not visible. Maybe this is just some chance outcome of the way I installed it, but it’s pretty great because largely hidden.

    Like

  3. This is great. I just added it to my search layout, but now I am wanting to edit the columns visible in the search view (existing ones aren’t very useful). Looks like SF hasn’t given end users the ability to customize this, but curious if you have a clever hack for displaying more/different fields when searching for Accounts to merge.

    Like

  4. This URL /merge/conmergewizard.jsp?id={!Account.Id}&retURL=/{!Account.Id} does not work for contact list view
    What is the URL to add a merge contacts button to the contacts list view

    Like

    • Hi,
      You cannot directly merge contacts like you merge Accounts. The platform doesn’t allow that, not even in Classic. Only Contacts which are related to one Account can be merged, so you must provide the Account Id in the URL, or else it will not work.

      Like

    • For something like that, you’ll have to create something custom using flows or lightning components and Apex.
      The Classic merge only searches the Name field. Although I couldn’t find any document supporting this statement but that seems to be the case from what I have tested.

      Like

  5. Hi, this solution worked great! However, with the Winter release 21′ I get an error message saying “xy has rejected the connection.” : (. Is there any workaround for this?

    Like

      • Hi, I just tried to send you the video and screenshot by replying to your message. However, I received an error.

        Like

      • Hi, please find following the link (hope this works…) https://www.dropbox.com/sh/58cx9cktp7rfqxp/AAAwVQ-LIFVpunM_9gbZaNMRa?dl=0

        Kind Regards,
        Benjamin

        NZZ-MEDIENGRUPPE

        Benjamin Aebischer
        Salesforce Administrator · Technologie

        Neue Zürcher Zeitung AG
        Falkenstrasse 12 · Postfach · CH-8008 Zürich
        Zentrale +41 44 258 11 11 · Direkt +41 44 258 29 07
        benjamin.aebischer@nzz.ch · http://www.nzzmediengruppe.ch

        Von: forcePanda
        Gesendet: Montag, 19. Oktober 2020 19:20
        An: Aebischer Benjamin
        Betreff: [New comment] Merge Accounts and Contact in Lightning like Classic

        ForcePanda commented: “You can store the video and screenshot in the cloud and share the link, if that works. I don’t think WordPress will allow posting videos in comments.”

        Like

      • I added the domain url to CSP Trusted Sites, but I still get the error : (. Any other idea?

        Kind Regards,
        Benjamin

        Von: forcePanda
        Gesendet: Montag, 19. Oktober 2020 19:47
        An: Aebischer Benjamin
        Betreff: [New comment] Merge Accounts and Contact in Lightning like Classic

        ForcePanda commented: “I see… Can you try adding your org’s domain URL to CSP trusted Sites in Setup? The url should be something like: https://BlahBlah.my.salesforce.com

        Like

      • Yes, I did earlier today. It would be a pity if the solution wouldn’t work anylonger.
        Thank you very much for your help!

        Kind Regards,
        Benjamin

        Von: forcePanda
        Gesendet: Montag, 19. Oktober 2020 20:00
        An: Aebischer Benjamin
        Betreff: [New comment] Merge Accounts and Contact in Lightning like Classic

        ForcePanda commented: “I’m running outta ideas. Will require some further investigation. Have you tried raising a ticket with support?”

        Like

      • Hi, I follow-up on this issue. Salesforce Support is still reviewing the case – So far, they couldn’t figure out what causes the issue. Do you maybe have any update? Kind Regards

        Like

      • Hey Benjamin,
        Thanks for the update.
        So I just looked at it and found the fix 😎. And it’s quite silly 😂

        All you gotta do is set the ‘Behavior’ as:
        Display in existing window without sidebar or header

        That worked in my SB, so should work for you! 🙂

        Like

  6. Hi,
    with the Winter release 21′ I get an error message saying “xy refused to connect.”. Is there any workaround for this?

    Like

  7. Hi,

    Same problem, I receive an error message “… refused to connect”, even though Org’s domain is added to CSP trusted Sites.
    This happens on the sandbox.

    Like

  8. Hi,
    Is it possible for case merge? I would like to create a custom button in the related list for cases with the same account. Thank you so much

    Like

    • Hi,

      In Spring ’20, Salesforce release Case Merge functionality in Lightning. Have you tried using that?
      To enable Case Merge: From Setup, enter Case Merge in the Quick Find box, then select Case Merge. Toggle Merge Cases to proceed to Case Merge settings.

      Like

      • Hi, yes I have used it but now I would like to use it in the related list view component. In case record page, we can have a related list component called “Cases for Parent Person Account”. I tried to make a custom button in order to merge cases but looks like it’s impossible to use this hack url for case merge in the lightning.. Like you mentioned, maybe because it is new feature.

        Like

      • Hi,
        I got it. Hope they will update this feature in order to use it in the related list component later on. Thank you for your time. Thank you so much.

        Like

      • Okay, so I was exploring a bit around this and I found a way which could work. The solution, however, is a bit hacky and involves writing some code(creating a lightning component), and also if the something on the Salesforce side changes, it might break and the solution may need a repair.

        Like

  9. Is this only for Admins? I can’t seem to figure out how to allow non-Admins access to use this button. When they click it, it gives them the “insufficient privileges” error.

    Like

  10. I was jut wondering if you know why I can’t add this custom button to the related list? I can only see standard buttons and no option for custom buttons.

    Like

  11. I have created the Merge Account/Contacts for Account detail page button. This button works fine however the returl is not working on lightning exp also once merge it throws error “Requested Page not available” with or without RetUrl is there a way to tackle this

    Like

    • Uh, if you’re trying return to the record which gets merged and deleted then you can expect this error.
      I can’t think of any ideal solution for the redirection issue. Best would be to redirect the user to a list view.

      Like

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.