Create Custom document template in D365 F&O

 

Hope you are doing great!

In D365 F&O, there is one great feature to view, edit and publish data that is "OPEN IN EXCEL". This feature uses some out-of-the-box Excel templates. By using these templates, you directly view, edit and delete data from Excel without any additional import/export functionality.

The standard Excel templates can be accessed from Organization Administration → Setup → Office → Integration → Document Templates. There is a download option to access the actual template file. If the standard Excel template does not meet your requirements, then the template needs to be modified. It is best to keep the standard one untouched and create a new entry template.
So, let’s see how to create new document template. I am using PriceDiscAdmTransEntity in this example.
Step 1: Create an excel resource file. Add PriceDiscAdmTrans data entity and map your desired fields on it.

Step 2: Add your excel resource file in the project and reference the resource name of this file in your class.

Step 3: Create template registration class. Extend your class to DocuTemplateRegistrationBase Which is a parent class to populate all document templates. Override registerTemplate() method and write following code to add your custom template along with system templates.



There is one standard or simple way is to view this template Go to D365O→ Organization administration→ Setup→ Office integration→ Document templates. Click “Reload system templates”. You will see the new template is added to the list. And you can run this through Price Journal lines form.

2nd way to run this template through code, interesting! We will see how to run this template for specific journal number as key filter.
Create a new class to run this template directly, below is code shown:


Hope it helps you!
Thanks

Comments