Printing PDF Attachments in MSDyn365FO

In this post I’ll detail how you can print PDF document attachments using AXs DocumentContract framework. I have used this forum post as a reference: https://community.dynamics.com/ax/f/33/p/222925/785091#785091
1. Create extension of the DocuView form to introduce a new Print button.
DocuViewExt
DocuViewForm
2. Next thing is to create a handler class that will have all our event handlers.
a. Firstly, we create a class with the reference to DocumentContract AX framework. In my case, I am also using Reporting framework.
DocuView_Ref
b. Let’s subscribe to the OnActivated event of the main DataSource which is DocuRef. This is so we can enable or disable printing by checking if the reference is a document and is of type ‘pdf’
DocuView_Activated
c. Then we can create subscribe to the OnClicked event of the new button Print button. We will write our printing logic here.
DocuView_Print
d. Once you click print, you’ll get the following message and you have managed to successfully print an attachment:
DocuView_PrintStatus

Comments

  1. Thanks Shahil , this is really helpful, i have the same requirement. but mine is to print a work or excel file, please let me know if that is possible also with the same code

    ReplyDelete

Post a Comment

Popular posts from this blog

Override a System Defined Refresh button in D365O