Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Create PO invoice without posting it using PurchFormLetter framework

Posted on by Microsoft Employee

Hi good folks,

I'd like to create a supplier pending invoice using the PurchFormLetter module without attempting to post it.

it seems that PurchFormLetter.StartOperation() && purchFormLEtter.update() will attempt to post the pending invoice after creating it.

I have thought about adding a parameter to the data contract and checking against that in the posting process but i am wondering if there is an existing parameter that will do that !

code looks like:

Purchformletter = purchformletter::construct(DocumentStatus::Invoice);
    
purchformletter.parmParmTableNum("InvoiceId");
Purchformletter.purchTable(purchtable); 

purchParmUpdate = purchformletter.purchParmUpdate();
purchParmUpdate.SumNum = "IGU + 20147856434-11";
    
purchformletter.initParameters(purchParmUpdate,
                        Printout::Current);  // Printout
purchformletter.chooseLines(true);
    
Purchformletter.selectFromJournal(selectedList.pack());

purchformletter.sumBy(AccountOrder::None);
purchformletter.reArrangeNow(true);
purchformletter.reArrange();
purchformletter.specQty(purchupdate::PackingSlip);

purchformletter.startOperation();


thanks for your help.

*This post is locked for comments

  • venkatpasumarthi Profile Picture
    venkatpasumarthi 125 on at
    RE: Create PO invoice without posting it using PurchFormLetter framework

    Hi Krishna,

    did you achieve this? I am having the same requirement. if yes, I would appreciate if you share your code.

  • Pete Alberts Profile Picture
    Pete Alberts 3,542 on at
    RE: Create PO invoice without posting it using PurchFormLetter framework

    Thank you for the post kind sir. This has proved helpful to me.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Create PO invoice without posting it using PurchFormLetter framework

    Hi Ievgen,

    Thanks for your code, I have a similar requirement to use the purchFormLetter framework to only pull lines from a PO into an already existing Pending vendor invoice header record. I don't want to create a new invoice record. How do I achieve this?

  • Martin Dráb Profile Picture
    Martin Dráb 230,235 Most Valuable Professional on at
    RE: Create PO invoice without posting it using PurchFormLetter framework

    Proforna invoices are not really posted, that's the whole point. Don't get confused by the fact that they need to do the same calculations and temporarily fill in the same tables to be able to print the invoice report.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Create PO invoice without posting it using PurchFormLetter framework

    Thanks for your input Martin, I tried the proforma option and it attempted to post it as well. but I need a normal invoice for my solution. thanks for your response, always appreciated.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Create PO invoice without posting it using PurchFormLetter framework

    Hi ievgen,

    absolutely brilliant thank you!

    I am creating the invoice using a product receipt supplied in the packed list. so moving the order of lines a bit i get exactly what i need "a pending PO supplier invoice from a product receipt" w/o form prompting or posting attempts.

    Final result for those interested:

    Purchformletter = purchformletter::construct(DocumentStatus::Invoice);

    purchformletter.parmParmTableNum("InvoiceNumber");

    Purchformletter.purchTable(purchtable);

    purchParmUpdate = purchformletter.purchParmUpdate();

    purchParmUpdate.SumNum = "InvoiceNumber";

    purchformletter.initParameters(purchParmUpdate, Printout::Current);  // Printout

    purchformletter.sumBy(AccountOrder::None);

    purchformletter.reArrangeNow(true);

    purchformletter.reArrange();

    purchformletter.specQty(purchupdate::ALL);

    purchformletter.chooseLines(true);

    Purchformletter.selectFromJournal(selectedList.pack()); //where product receipt is supplied

         VendInvoiceInfoTable::moveFromActiveToSaved(VendInvoiceInfoTable::findRecId(purchformletter.parmLastParmTableRecId()));

  • Martin Dráb Profile Picture
    Martin Dráb 230,235 Most Valuable Professional on at
    RE: Create PO invoice without posting it using PurchFormLetter framework

    Wouldn't a proforma invoice do the job? (Maybe not, I'm not sure what exactly it saves.)

    Note that if you want to know what the framework does (such as which parameters it considers), you can look into its code.

    (I see I was too late and Ievgen has probably a better answer, but I'll keep it here for completeness.)

  • Verified answer
    Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: Create PO invoice without posting it using PurchFormLetter framework

    Hi Zain,

    You don't need to call neither startOperation nor update. chooseLines will create VendInvoiceInfoTable and VendInvoiceInfoLine for you and all you need is to make it pending.

        purchParmUpdate purchParmUpdate;
        PurchTable purchtable = purchtable::find('POxxxxx');
        PurchFormLetter purchFormLetter = PurchFormLetter::construct(DocumentStatus::Invoice);
        purchformletter.parmParmTableNum("xxxxx");
        purchformletter.purchTable(purchtable); 
        purchformletter.specQty(purchupdate::All);
        purchParmUpdate = purchformletter.purchParmUpdate();
        purchParmUpdate.SumNum = "xxxxx";
    
    
        purchformletter.initParameters(purchParmUpdate,
                                Printout::Current);  // Printout
        purchformletter.chooseLines(true);
        VendInvoiceInfoTable::moveFromActiveToSaved(VendInvoiceInfoTable::findRecId(purchformletter.parmLastParmTableRecId()));

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 Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans