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. 🙂
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
LikeLike
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.
LikeLike
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.
LikeLike
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.
LikeLike
I really doubt if there is a way to do that. But if there is(or I figure out some way), wouldn’t miss blogging about it for sure!
LikeLike
What if we’re using account/contact relationships vs. standard contact related list. Any hack for that?
LikeLike
Hi Justin,
You can create a very similar button on the Account Contact Relatioship object from the Setup and add it to the Related list in the Account page layout.
LikeLike
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
LikeLike
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.
LikeLike
Hi,
How are creating that drop down for Merge Account button?
LikeLike
Hi Kriss,
You will have to add your list type button to the list view. Please note that button will not appear on Recently Viewed list view, it’s a platform limitation.
LikeLike
What if I want to merge two accounts that have completely different names?
LikeLike
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.
LikeLike
Hi, it is possible that this is not working anymore with release 21?
LikeLike
Not sure.
What’s happens when you are trying to use this? Does it throw you an error or what?
LikeLike
P.S. Both Merge Accounts and Merge Contacts seems to be working fine in my dev org.
LikeLike
Hi Daniel,
One fix seems to be working. I’ve updated the post, check the “Update Winter 21” section towards the end of the post.
LikeLike
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?
LikeLike
Both Merge Accounts and Merge Contacts seems to be working fine in my dev org. Can you share the steps or a video link so I can try to reproduce the issue?
LikeLike
Hi, I just tried to send you the video and screenshot by replying to your message. However, I received an error.
LikeLike
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.
LikeLike
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.”
LikeLike
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
LikeLike
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“
LikeLike
I’m running outta ideas. Will require some further investigation but I can’t access your org. Have you tried raising a ticket with support?
LikeLike
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?”
LikeLike
Do tell how it goes. Based on what support says we can discuss it further. I may have some ideas that are worth trying but that’d be my last option.
LikeLike
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
LikeLike
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! 🙂
LikeLike
Wow, you’re a genius! Thank you so much! The solution is woking again : ).
LikeLike
Hi,
with the Winter release 21′ I get an error message saying “xy refused to connect.”. Is there any workaround for this?
LikeLike
Weird. It still works in my dev org though.
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
Also, could you try this in your dev org as well?
LikeLike
Hi,
One fix seems to be working. I’ve updated the post, check the “Update Winter 21” section towards the end of the post.
LikeLike
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.
LikeLike
I’ll have to test this in a SB maybe then.
P.S. Have you tried logging a case with support?
LikeLike
One fix seems to be working. I’ve updated the post, check the “Update Winter 21” section towards the end of the post.
LikeLiked by 1 person
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
LikeLike
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.
LikeLike
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.
LikeLike
I did some digging to check if the button can be called via URL, no luck unfortunately.
LikeLike
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.
LikeLike
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.
LikeLike
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.
LikeLike
Those need to have the right permissions in order to merge accounts.
Check the “User Permissions…” section in this article:
https://help.salesforce.com/articleView?id=sf.account_merge_classic.htm&type=5
LikeLike
Yes, I actually figured it out just after I commented. That particular profile didn’t have Delete permission on Contacts. They do now and your solution works perfectly!
Can you do this for leads as well?
LikeLike
I think so, yes.
You will need create a URL button, and the url would look like this:
/lead/leadmergewizard.jsp?
retURL=/{Lead.Id}
&id={Lead.Id}
LikeLike
I’m getting this error “Invalid Page Redirection
The page you attempted to access has been blocked due to a redirection to an outside website or an improperly coded link or button.” with that URL.
LikeLike
Can you post the url that you’re using?
LikeLike
/lead/leadmergewizard.jsp?retURL=/{Lead.Id}&id={Lead.Id}
LikeLike
This URL should work:
/lead/leadmergewizard.jsp?
retURL=/{!Lead.Id}
&id={!Lead.Id}
The previous one had incorrect merge field syntax. 🙂
LikeLike
So sorry, but now it’s giving this error:
“Unable to Access Page
The value of the “id” parameter contains a character that is not allowed or the value exceeds the maximum allowed length. Remove the character from the parameter value or reduce the value length and resubmit.”
LikeLike
It’s working for me.
Can you try manually typing it? There might be some hidden character(s).
LikeLike
Unfortunately, I am still getting the same error, even after manually typing it.
LikeLike
Can you share a snapshot of your button configuration page?
LikeLike
Ok, dropped the screenshot on your SF Community page.
LikeLike
Thank you for letting me know to change it to the detail page button. That allowed the button to function. We are fully in Lightning, but when I click the button, It is opening up in Classic. Is that what is expected?
LikeLike
Yeah, that’s the odd thing about it. I tried few things to check if we can make it less “Classic” but no luck.
I’d suggest exploring AppExchange. You might find some free utility components for your use case. 🙂
LikeLike
Great idea! Thank you SO MUCH for everything you have helped me with over the last week! You are amazing!! I appreciate you so much!
LikeLike
Glad I could help! 🙂
Have an amazing weekend!
LikeLike
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.
LikeLike
You’ll need to add the button to the related list from the page layout.
LikeLike
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
LikeLike
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.
LikeLike
“conmergewizard.jsp?” is this part is like standard or we have something behind this?
LikeLike
It’s standard Salesforce feature.
LikeLike