web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Create an action after posting a vendor invoice journal from a purchase order though X++

(0) ShareShare
ReportReport
Posted on by 55

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.

0535.pastedimage1651858232935v1.png

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?

  • Gunjan Bhattachayya Profile Picture
    35,429 on at

    Hi Chris,

    You might want to try postPurchaseOrderInvoice method in FormLetterService class. You will need to get the posted invoices. So, while posting a PO invoice, you can select the print invoice option and debug the printJournal method in the same class. You could then use similar logic to get all the VendInvoiceJour records for sending emails.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 543 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 415 Super User 2026 Season 2

#3
CU-1234529-002 Profile Picture

CU-1234529-002 188

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans