mscrm-addons.com - Blog

IMPORTANT INFORMATION

This blog is deprecated since July 2020.The articles below are no longer maintained and might contain outdated information. 
You can find the most acutal and relevenat information in our Knowledge Base at support.mscrm-addons.com

News.mscrm-addons.com Blog

rss

Hello and welcome to our blog! What can we do for you? Are you looking for further technical information or step-by-step instructions to our products? Or would you like to read the latest news on mscrm-addons? Please feel free to browse our blog for detailed information and to share our posts!


Custom ExportToWord Buttons in DocumentsCorePack for Dynamics 365

This article describes how you can create custom Dynamics 365 menu buttons with custom JavaScript functions to execute the DocumentsCorePack ExportToWord (aka “PrintInWord”) process. This article is only relevant if you use the DocumentsCorePack client (Template Designer) to generate documents.

 

This blog article applies only to Dynamics 365 version 8.2 and higher. 

 

Basic JavaScript knowledge is required.

 

When can this be helpful?

For example, you want to define a specific template which should be used for the process.

Or you want to do any pre-operations like checking the status of the target record (e.g. invoice has to be paid).

 

Configure custom buttons

First, start the Configuration - DocumentsCorePack for Dynamics 365, connect to your organization and launch the Client & Server Based generation settings.

More information can be found in chapter “Organization Overview“ of the Install Guide

 

In the so opened window, hit on the [Advanced Button Configuration]-button, like you can see in the following figure.

Thereafter the Advanced Button Configuration-dialog will appear. In this dialog, you can select the entity that you want to manage.

E.g. Already existing custom [Export To Word]-buttons will be listed and can be deleted.

 

If you press the [Add]-button, the following Edit button-dialog opens. 

 

JavaScript functions 
The methods described below are part of this web resource. The latest version of the script can be download here.

The function ptmDCPCustomExportToWordAction (line 33 to 43) shows the simplest way to start the ExportToWord process. After executing, the DCP Client will show the template selection dialog. This example function is ready to use and works for different entities.

 

ptmDCPCBCustomButton.startExportToWord(selectedIds, typeCode, selectedItemCount, entityName);

This function starts the ExportToWord process, like you can see in the following figure.

The function ptmDCPCustomExportToWordActionAccountWithTemplate (line 46 to 58) shows how the ExportToWord process can be started with a specific template. After executing, the DCP Client will use the defined template (Account_Overview.docx) instead of showing the template selection dialog.

This example function works for accounts only because its template is designed for accounts.

 

//doSomething();

Can be replaced with any custom code. E.g. check the status.

var nameOfDCPTemplate = "Account_Overview.docx";

Define the name of the DCP template. Any existing template of the entity account can be used.

 

ptmDCPCBCustomButton.startExportToWord(selectedIds, typeCode, selectedItemCount, entityName, nameOfDCPTemplate);

Starts the ExportToWord process and passes on the template.

The function ptmDCPCustomExportToWordActionSingleRecordCheck (line 63 to 96) shows how the entity name and the ID of the reference-record can be accessed (first for a process started from GRID/SubGRID, second from a FORM).

Finally, it starts the ExportToWord process.

You can add custom functions to the web resource as well. Ensure that you use the same input parameters as the sample functions have.

Therewith your custom functions can be selected in the DocumentsCorePack dialog they have to be placed above on the line ///////// DCPHELPERFUNCTIONS /////////




Comments are closed.