Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

x++ Multiple POs in single invoice

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello,

Can someone please share the code to post single invoice for multiple Purchase orders through x++.

These are service item purchase orders so packing slip is not required.

I am able to create invoice for inidividual purchase order but struggling to crease single invoice for multiple purchase orders.

I am using ax 2012 R2.

An urgent feedback will be highly appreciated.

Thanks.

*This post is locked for comments

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: x++ Multiple POs in single invoice

    The following code will post single invoice against multiple purchase orders.

    static void Bilal_postPOMultiple(Args _args)

    {

       PurchFormLetter                 purchFormLetter;

       //PurchTable _purchTable = PurchTable::find("000592");

       PurchTable          purchTable;

       Map                 mapPurchTable;    

       ttsBegin;

       // Confirm order

       //purchFormLetter = purchFormLetter::construct(DocumentStatus::PurchaseOrder);

       //purchFormLetter.update(_purchTable,'');

       // Invoice order

       purchFormLetter = purchFormLetter::construct(DocumentStatus::Invoice);

       mapPurchTable = new Map(typeName2Type(extendedTypeStr(RecId)), Types::Record);

       purchTable = PurchTable::find("001228");

       mapPurchTable.insert(purchTable.RecId, purchTable);

       purchTable = PurchTable::find("001229");

       mapPurchTable.insert(purchTable.RecId, purchTable);

       purchFormLetter.parmDataSourceRecordsPacked(mapPurchTable.pack());

       purchFormLetter.initNewPurchParmUpdate();

       purchFormLetter.sumBy(AccountOrder::Account);

       purchFormLetter.reArrangeNow(true);

       purchFormLetter.update(purchTable,

                              "In4f9231",

                              systemDateGet(), PurchUpdate::All);

       ttsCommit;

    }

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,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans