Client Requirements: Word 2016 or greater
Note: It's not possible to do automation with the Click-To-Run Office editions. It's due to the virtualization process used. ref: https://stackoverflow.com/questions/3372394/is-it-possible-to-automate-a-click-to-run-application
- Dec 2018 - One click buttons can now be created
- July 2018 - Microsoft Excel Mail Merge Released - Details below
The mail merge application is available for download from the Accelerator page on My CRM.
This application only runs on windows and requires Microsoft word to be installed on the client.
It registers a URI (custommailmerge:)
This can be used from the BrowserX app or by coding its use into CRM (using client-side script or ASP code)
The Parameter is the full CRM URL
Example of a full link custommailmerge:http://serverOrIP/CRM/eware.dll/Do?SID=9425127913187&Act=200&Mode=1&CLk=T&Key0=1&Key1=56&Key2=70&T=Company
One click buttons (available from Dec 2018 release 18.104.22.168)
To add a one click button you need to select the method and also get the document ID (Library id and not the name)
opt_MailMerge opt_EmailAtt opt_MailMergeCsv (excel) opt_DownloadData opt_EmailDocument opt_PrintDocument
opt_MailMerge = Mail Merge opt_EmailAtt = Email with attachment opt_MailMergeCsv (excel Merge) opt_DownloadData = Download the data opt_EmailDocument = Email with document embedded opt_PrintDocument = Print the document
Here we have an example of a button for a custom entity being added
Container.AddButton(CRM.Button("Email Merge Doc","edit.gif","custommailmerge:http://crm.server.com/crm/CustomPages/Policy/PolicySummary.asp?mpol_PolicyID="+UseId+"&SID="+_sid+"&F=&J=Policy/PolicySummary.asp&Key0=58&ctfunc=opt_EmailAtt&ctdoc=10167", "Policy", "EDIT"));
You can see the
ctdoc=10167 has the document id
With the "Email with attachment" option you can specify a view that has the following fields aliased
customFileName customEmailTemplate customEmailTo customEmailCC customEmailBCC
CREATE VIEW vCTProjectMailMerge AS select 'Project_'+Convert(nvarchar,ctpr_CTProjectID) as 'customFileName', 'Project Template' as customEmailTemplate, 'email@example.com' as 'customEmailTo', 'firstname.lastname@example.org' as 'customEmailCC', 'email@example.com' as 'customEmailBCC', CTProject.*, vcommunication.Comm_Description, vcommunication.Comm_Note from CTProject left join vcommunication on ctpr_CTProjectID =Comm_CTProjectId
and these allow you to name the file your own custom name, use a CRM email template and also specify the recipient fields.
This application is the replacement for how you mail merge from the IE toolbar.
One difference is that you can also edit/merge an existing document and re-upload this (as a new record) into CRM.
Mail Merge Application incorporates several other features from the IE toolbar, such as:
- "Email Document" - Immediately process without the option to edit opening an email and embedding the document
- "Email Mail Merge Attachment" - Completes the mail merge and opens an email attaching a PDF of the merged document
- "Print Document" - Immediately print without the option to edit.
- "Download Merge Data" - Allows you to save the data from a view to use when building a new Mail Merge document
Demo video at
Released 31 January 2017 as part of 4.5.3
To add in a Mail Merge button on a custom entity you just add in something like the following to the summary page:
var xurl = "custommailmerge:http://22.214.171.124" + CRM.url("CTProjects/CTProjectsSummary.asp?J=CTProjects/CTProjectsFind.asp&E=CTProjects"); Container.AddButton(CRM.Button("Mail Merge","edit.gif",xurl, "CTProjects", "EDIT"));
Microsoft Excel Mail Merge
So new to Accelerator for Sage CRM(Release 126.96.36.199c 24 July 2017) is the ability to use Microsoft Excel files as templates and merge CRM data to them
In the past Accelerator for Sage CRM has had client-side mail merge to Microsoft Word. Excel itself doesn’t have a mail merge function but the developer working on this was clever enough to use the #prefix_fieldname# (EG #oppo_description#, #comp_name#) to allow you create Excel files as templates and put these tags in which are then replaced with the actual data.
As with the Word merge you can specify any view in the CRM database to be used with a given template so this makes it really flexible.
I should also mention that with the mail merge app you can see existing documents (maybe previously merged and saved to Sage CRM) and get a copy of those and create a new version. So you don’t have to finish a document in one go and can use CRM to store versions of this document.
To merge to line items you create a line item row and then insert a row above and in the first cell enter
This line below is used as a template and replicated for each item*.
- the view used against the document must return a line for each item
The code for the buttons is in a file called ct_browserx.js
located on the CRM server at
C:\Program Files (x86)\Sage\CRM\CRM\WWWRoot\js\custom
To uninstall the app delete this file.
Mail Merge on Quotes/Orders
The views used for the quote and order items are
The item table should only have a header and a line that starts with with of the mail merge tags
<<TableStart:QuoteItems>> or <<TableStart:OrderItems>>
DO not create a 3rd line for the totals as this will break the merge. Instead create a separate tab.
How to iterate through the data rows (where you might be merging to something like a quote)
In the data that is downloaded there is a column called
The last row has a value of 1
So within word you can use the rule
Next Record If
The reason you would need to do this is so you do not go past the last record and you can then display your totals for example.
The defaults for this screen are set via the server web.config file
<add key="comm_action" value="LetterOut"/> <add key="comm_status" value="Complete"/> <add key="comm_priority" value="Normal"/>
and also via the specific template setting for
libr_category and libr_type