Hello,
I'm working with Dynamics 365 Finance and Operations,
The requirement is that when someone posts a pending vendor invoice from a purchase order by clicking "Post" on the vendor invoice form, an Email has to be sent with the preview report of the invoice journal.
I already have the class created and working, the only thing left is make it run after the vendor invoice is posted.
I tried to make a class extension of the PurchFormLetter.run() method, the method is called when I post the PO, I need to get either the PurchTable purchId or the VendInvoiceJour record to sent them to my class, but I can't find the way to get them from PurchFormLetter, this is my code:
[ExtensionOf(classStr(PurchFormLetter))] final class ATXPurchFormLetter_Extension { public void run() { PurchTable purchTableAlt = this.purchTable(); VendInvoiceJour vendInvoiceJour; SendInvoiceReportEmail emailEngine = new SendInvoiceReportEmail(); info("before run"); next run(); info("after run"); while select vendInvoiceJour where vendInvoiceJour.PurchId == purchTableAlt.PurchId { emailEngine.sendEmail(vendInvoiceJour); } } }
I tried getting the purchTable() method to get PurchTable, but it's not returning any data.
Is there a way I can get those records from the class? Do I have to extend another class or method?