Automatic creation of a PDF from a customer invoice in Dynamics Ax 4.0

 
Good morning,
 
The following code snippet will create a PDF from a CustInvoiceJour record, without any user intervention, using only the standard Ax4 EPSendDocument class.
 
public static void EPSendDocumentTest(Args _args)
{
    EPSendDocument sendDocument;
    CustInvoiceJour custInvoiceJour;
    Filename filename;
    ;
 
    select firstonly custInvoiceJour;
 
    filename = WinAPI::getTempPath() +’MyInvoice.pdf’;
    sendDocument = new EPSendDocument(custInvoiceJour);
    sendDocument.parmOriginal(true);
    sendDocument.parmFileName(filename);
    // Make document will run the report and send it to a PDF file with
    // the path specified in filename
    sendDocument.makeDocument();
}
 
The file should end up in C:\DOCUME~1\***\LOCALS~1\Temp\MyInvoice.pdf on Win32 installations. I found this while looking at EP weblet ‘EPDocuGetWeblet’. The EPSendDocument class supports a lot of other standard reports, such as quotations, etc.
This entry was posted in Dynamics Ax 4.0x. Bookmark the permalink.