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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Creating an invoice for multiple POs.

(0) ShareShare
ReportReport
Posted on by 59

I haven't found a solution online for this yet and it seems I have run across this error but no valid solution yet.

Error when invoicing invoice number: TestMultPOs on Purchase Order: PO-012-031705 The purchase order or product receipt was corrected after the vendor invoice was created.
All accounting distributions must be re-created to reflect any changes to the purchase order's or product receipt's accounting distributions.

I have x++ code that looks up a purchase order in ax 2012.  It will generate the vendInvoiceInfoTable, vendInvoiceInfoSubTable, vendInvoiceInfoLine_Asset, and vendInvoiceInfoSubLine with the product reciepts. I have been able to post and invoice just fine.

The issue is when I want to add multiple lines in vendInvoiceInfoLine that have a different Purchase order.  I get this error everytime and i'm not sure what parameter needs to be set or what do I need to do to get this to work. It works fine in the front end of course.  I can post my code if we need details but wondering on a high level first if anyone knows the answer to this.

One thing I did notice is when i invoice through code it looks like this in the front end. pastedimage1580921340301v1.png

When i invoice in the front end without going through code, it looks like this pastedimage1580921369753v2.png

The difference I can tell is the Purchase order field says <multiple> .. Something i need to fix there i bet as well  as the actual option to post under actions (the button) dissapears.. any ideas thanks?

I have the same question (0)
  • Suggested answer
    Ludwig Reinhard Profile Picture
    Microsoft Employee on at

    Hello Sirus49,

    Not sure if I understand your question correctly but if you are looking for a parameter that summarizes the different POs then have a look at AP/Setup/SummaryUpdate Parameters.

    Depending on what has been setup there and whether you select the arrange button in the invoice form, different invoices are summarized.

    Hope this helps.

    Best regards,

    Ludwig

  • Suggested answer
    André Arnaud de Calavon Profile Picture
    300,904 Super User 2025 Season 2 on at

    Hi Sirus,

    Have you actually tried to add lines from other purchase orders using your coding? In the front end, it will also fill a table with a link between the "main" PO of the invoice and related invoices. I don't know the name by heart.

    When this is filled correctly, the Purchase order field will automatically show also <multiple> as it is a display field.

  • Sirus49 Profile Picture
    59 on at

    Yes, i have tried to add lines from other POS and it does show up in the invoice... I just tried populating vendInvoiceInfoSubTable with the other PO and now it does show multiple as the display field for Purchase Order in the invoice.

  • André Arnaud de Calavon Profile Picture
    300,904 Super User 2025 Season 2 on at

    Hi Sirus,

    Has your question been answered or is there anything else in relation to this question?

  • Sirus49 Profile Picture
    59 on at

    Well just curious. Say if you have this code:

                                          vendInvoiceInfoSubTable.clear();

                                          vendInvoiceInfoSubTable.initValue();

                                          vendInvoiceInfoSubTable.defaultRow();

                                          vendInvoiceInfoSubTable.ParmId = vendInvoiceInfoTable.ParmId;

                                          vendInvoiceInfoSubTable.OrigPurchId = purchLine.PurchId;

                                          vendInvoiceInfoSubTable.TableRefId = vendInvoiceInfoTable.TableRefId;

                                          vendInvoiceInfoSubTable.PurchName = purchtable.PurchName;

                                          vendInvoiceInfoSubTable.insert();

    Basically you look up the Main PO first and add lines to that PO.  Then you have the linking table for each different PO you add a record. so vendInvoiceInfoSubTable.OrigPurchId = purchLine.PurchId will be the a line from the main PO and then another record vendInvoiceInfoSubTable.OrigPurchId = purchLine.PurchId with the other PO.  Should the rest of the parameters be the same from the main po where you originally initialized?. hopefully that makes sense.

  • Sirus49 Profile Picture
    59 on at

    Also now that I populate the table both showing Multiple for PO and Product Receipt through code.  When I save it without invoicing through code and go to the front end, it seems fine no errors and can post.  But when I post through code instead using below. I still manage to get that Error:

    The purchase order or product receipt was corrected after the vendor invoice was created.

    All accounting distributions must be re-created to reflect any changes to the purchase order's or product receipt's accounting distributions

                  purchFormLetterInvoice = PurchFormLetter_Invoice::newFromSavedInvoice(vendInvoiceInfoTable);

                   purchFormLetterInvoice.showQueryForm(false);

                   purchFormLetterInvoice.specQty(PurchUpdate::PackingSlip);

                   purchFormLetterInvoice.update(vendInvoiceInfoTable, vendInvoiceInfoTable.Num, systemdateget());

  • Suggested answer
    A.Prasanna Profile Picture
    8,223 on at

    I think for this you can use consolidation feature with less effort to achieve  this.

    just refer https://vsdynamicsfinance.wordpress.com/2014/02/20/create-one-invoice-for-two-purchas-orders/ .

    Thanks & Regards,

    Amith Prasanna

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 663 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 540 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 348 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans