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 :
Microsoft Dynamics AX (Archived)

Create PO invoice without posting it using PurchFormLetter framework

(1) ShareShare
ReportReport
Posted on by

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

  • Verified answer
    Mea_ Profile Picture
    60,286 on at

    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()));
  • Martin Dráb Profile Picture
    240,833 Most Valuable Professional on at

    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.)

  • Community Member Profile Picture
    on at

    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()));

  • Community Member Profile Picture
    on at

    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.

  • Martin Dráb Profile Picture
    240,833 Most Valuable Professional on at

    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
    on at

    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?

  • Pete Alberts Profile Picture
    3,546 on at

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

  • venkatpasumarthi Profile Picture
    125 on at

    Hi Krishna,

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

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 > 🔒一 Microsoft Dynamics AX (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans