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 :
Finance | Project Operations, Human Resources, ...
Unanswered

Invoice Posting Fails with Matching Errors Must Be Approved using x++

(0) ShareShare
ReportReport
Posted on by 502
Hi Everyone,
 
I use the following code to confirm the PO, create the product receipt, and then post the invoice.
The confirmation and product receipt steps are working correctly, but the invoice posting fails with the following error:
 
Invoice: INV-019231
Invoice INV-019231 could not post because it contained matching errors which must be approved.
Posting of order PO-N-9000897 canceled
Question:
What could be wrong in my code or what am I missing?
Note:
3-way matching is enabled in the system.


Here is the X++ code:

 
PurchTable purchtable;
PurchFormLetter purchConfirm;
PurchFormLetter purchPackingSlip;
PurchFormLetter purchInvoice;

purchTable = PurchTable::find("PO-N-9000897");

// Confirm PO
purchConfirm = PurchFormLetter::construct(DocumentStatus::PurchaseOrder);
purchConfirm.update(
    purchTable,
    purchTable.PurchId,
    systemDateGet(),
    PurchUpdate::All,
    AccountOrder::None,
    NoYes::No,
    NoYes::No
);
purchtable.reread();

// Product Receipt
purchPackingSlip = PurchFormLetter::construct(DocumentStatus::PackingSlip);
purchPackingSlip.update(
    purchTable,
    null,
    systemDateGet(),
    PurchUpdate::All,
    AccountOrder::None,
    NoYes::No,
    NoYes::No
);
purchtable.reread();

// Invoice
purchInvoice = PurchFormLetter::construct(DocumentStatus::Invoice);
purchInvoice.update(
    purchTable,
    "INV-019231",
    systemDateGet(),
    PurchUpdate::All,
    AccountOrder::None,
    NoYes::No,
    NoYes::No
);


 
I have the same question (0)

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 493

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 413 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 242 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans