Skip to main content

Notifications

Announcements

No record found.

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
    Gunjan Bhattachayya 35,421 on at
    RE: Create an action after posting a vendor invoice journal from a purchase order though X++

    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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,431 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,503 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans