While you can switch to Classis Salesforce and use the Mail Merge functionality from there, you can easily add a custom button to the Account or Contact object layout to open within Lightning.
First navigate to the Object Manager and choose the object you will add the button on. For this example we will use the Account Object because our templates are populated with fields from here.
- Select Buttons, Links, and Action from the list on the left and click the New Button or Link
- Label the button ‘Mail Merge’ and choose Detail Page Button.
- Select Display in new window as the Behavior and URL for Content Source.
- Copy the following into the text box:
https://<YOUR-ORG-NAME> .my.salesforce.com/mail/mmchoose.jsp?id={!Account.Id}&1={!Account.Name}&retURL=https://<YOUR-ORG-NAME> .lightning.force.com/lightning/r/Account/{!CASESAFEID(Account.Id)}/view?0.source=alohaHeader
NOTE: Replace <YOUR_ORG_NAME> with the name of your organization when logged into Salesforce Classic and Lightning. Remove any spaces from the hyperlink after copying
- Click Save.
Navigate to the object’s layout(s) to add the button to the page.
- Select Mobile & Lightning Actions from the list on the left and drag the Mail Merge button to the Salesforce Mobile and Lightning Experience Actions
- Click Save and test your button. When you click on the Mail Merge button from the Account Page the Classic Mail Merge page will open. Choose the desired template to merge and perform as usual.
This is a very helpful article. I’m wondering if you have found a way to mass mail merge Opportunities? I’m helping a small non-profit that could use that functionality.
Thanks,
Tim
Hi Tim,
Here are some ways to do Mass Document Mail Merges:
1. Can be done with apex code similar to Send List Mail.
2. Visual Force pages that open in Word with an apex data controller can be used.
3. Some will export the data they need from a SF report to Excel and then create Word merge documents with the Excel sheet as the source.
4. If the office is using the latest Office 365, they may be able to connect directly to Salesforce from Excel for the Data Source.
5. There are some free Excel Addins for Salesforce (e.g., XL Connector) that can be used for the Data Source.
6. There some ODBC drivers for Salesforce (e.g., Devart) that can used as the Data Source.
I hope that helps,
Becci
Always Chrome. Got it to work, but an issue with Person Accounts. It will merge properly on Business Accounts (which is the original Record Type), but not merging for Residential Accounts (which is the Record Type created for Person Accounts). Not sure why this would cause a problem.
That’s great! Person accounts will work differently to get the names and information into the template. I have found the best way is to put a lookup field on the Household Account for the Person records that you need. For example the primary person on the Household. That way you can get the fields you need by using Account.PersonFieldName__r.Name or Account.PersonFieldname__r.billingaddress. into the template.
I hope this helps :-).
Becci
HI Becci
I’m getting the following error when I test the button. Got any idea how I fix this? I checked the syntax in the box and it says it’s fine
Mary beth
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. Please contact your salesforce.com Administrator for assistance. For more information, see Insufficient Privileges Errors.
Click here to return to the previous page.
Mary Beth,
Check the URL you are adding by putting it into a browser window. If the page opens correctly, check if your org is set up to allow for redirection to outside websites.
Can you go into more detail about fixing this error, as I’m getting it as well, and I can’t find a good guide on setting up redirection permissions.
Bosh,
What browser are you using? If not Chrome, try it in that. Some browsers do not do redirection from Salesforce. I would also look to see if your Org is configured to allow redirection or add the URL to Trusted URLs for Redirects in Setup –> Session Settings. https://help.salesforce.com/s/articleView?id=sf.security_external_redirects.htm&type=5
The recent Salesforce updates have been making changes to MyDomain and how redirection is allowed so also make sure your Org is update on those changes as well.
Becci
Mary Beth,
What browser are you using? If not Chrome, try it in that. Some browsers do not do redirection from Salesforce. I would also look to see if your Org is configured to allow redirection or add the URL to Trusted URLs for Redirects in Setup –> Session Settings. https://help.salesforce.com/s/articleView?id=sf.security_external_redirects.htm&type=5
The recent Salesforce updates have been making changes to MyDomain and how redirection is allowed so also make sure your Org is update on those changes as well.
Becci
Hi,
This is useful and I’m testing it in the sandbox environment. The problem we have is that I get the “Unable to Access Page” message.
You are missing information needed by the page you have attempted to access. If you believe this is an error, please refresh your screen. If the error persists, please report it to our Customer Support team and provide the URL of the page you were requesting as well as any other related information.
Do you know what the issue is?
Hi Eva,
Are you putting the Sandbox URLs in the script or the production URLs? If the former, try it with the Sandbox URL instead. If the latter, make sure you have forwarding enabled in the Org so it will allow you to go to a difference URL. MyDomain settings could also effect it if Production is using it and Sandbox is not.
I hope that helps,
Becci
Hi Becci,
I’ve replaced it all with the sandbox URLs. It seems like I get that error message if the “Log an Activity” checkbox is checked off. This is also for the mail merge on Cases.
Thanks,
Eva
Hi Eva,
I am not sure as I have not tested in Sandbox and whether all would work there. If it works with check box unchecked then you may not be able to create history using this method. If the code is not working at all, feel free to post it and I can look at it.
You can also try testing in Production as there may be a limitation in Sandbox.
Becci