This blog article applies only to Dynamics 365 - version 8.2 and higher.
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.
Gives you the possibility to define a custom name for your button.
Cannot be changed.
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.
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 /////////
That’s it! We appreciate your feedback! Please share your thoughts by sending an email to firstname.lastname@example.org.