Infor CRM (formerly Saleslogix) Web Client- Running a Mail Merge From a Button

The client side MailMergeService allows running a mail merge against.  The nice thing about using this library is it gives you access to pretty much everything the Write menu does and it incorporates validating the client has the Desktop Manager in place.

There are 2 primary variables to work with in dealing with this service. 

  1. The Mail Merge Template’s PluginID
  2. The Contact ID

 Lets take a look at a javascript function that accepts these two variables as string inputs and then runs a mail merge.  There are other parameters withing the function, most are self-explanatory:

    function DoMailMergeService(pluginId, contactId) {
        require([‘Sage/MailMerge/Service’], function () {

            var contextSvc = Sage.Services.getService(‘ClientEntityContext’);
            var context = contextSvc.getContext();
            var contactId = context.EntityId;

            var oService = Sage.MailMerge.Helper.GetMailMergeService();
            if (oService) {
                var oMailMergeInfo = new oService.MailMergeInformation();
                var strLiterature;
                var iLiteratureCount;
                oMailMergeInfo.BaseTable = ‘CONTACT’;
                oMailMergeInfo.DoHistory = true;
                oMailMergeInfo.EditAfter = true;
                oMailMergeInfo.EditBefore = false;
                oMailMergeInfo.DoAttachments = true;
                oMailMergeInfo.AttachmentPath = Sage.MailMerge.Helper.MailMergeInfoStore().AttachmentPath; ;
                oMailMergeInfo.LibraryPath = Sage.MailMerge.Helper.MailMergeInfoStore().LibraryPath;
                oMailMergeInfo.FileDirectory = oService.MailMergeGUI().GetPersonalDataPath(); //Needed for otFile Output
                oMailMergeInfo.MergeSilently = false;
                oMailMergeInfo.TemplatePluginId = pluginId;
                oMailMergeInfo.MergeWith = MergeWith.withEntityIds;
                oMailMergeInfo.EntityIds = contactId;
                oMailMergeInfo.OutputTo = OutputType.otFile; //otEmail //otFile //otFax //otPrinter;
                oMailMergeInfo.UseTemplateDocProperties = false; // true;                           
                oMailMergeInfo.ExecuteMailMerge();
            }
        });
    }

ABOUT THE AUTHOR

Kris Halsrud

Kris Halsrud is a Senior Analyst / Developer for Customer FX Corporation.

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) news and product updates!

You have Successfully Subscribed!