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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Failure on creating purchase invoice header from custom extension page

(1) ShareShare
ReportReport
Posted on by 7
Consider the below extension page:
page 60000 AAA_PurchaseInvoiceAPI{    PageType = API;    Caption = 'AAA PurchaseInvoiceAPI', Locked = true;    APIPublisher = 'aaa';    APIGroup = 'group1';    APIVersion = 'v5.1';    EntityName = 'purchaseinvoice';    EntitySetName = 'purchaseinvoices';    SourceTable = /Purchase Header/;    SourceTableView = where(/Document Type/ = filter(Invoice));    DelayedInsert = true;    ODataKeyFields = SystemId;    layout    {        area(Content)        {            repeater(GroupName)            {                field(DocumentType; Rec./Document Type/)                {                    Caption = 'DocumentType', Locked = true;                }                field(DocumentNo; Rec./No./)                {                    Caption = 'DocumentNo', Locked = true;                }                field(DueDate; Rec./Due Date/)                {                    Caption = 'DueDate', Locked = true;                }                field(BuyFromVendorNo; Rec./Buy-from Vendor No./)                {                    Caption = 'BuyFromVendorNo', Locked = true;                }### SOME MORE FIELDS...                field(SystemId; Rec.SystemId)                {                    Caption = 'SystemId', Locked = true;                }            }        }    }
 
In some environments (with only this extension deployed) We cannot create purchase header via API
URL=
https:/api.businesscentral.dynamics.com/v2.0/tenantID/env_ID/api/stampli/group1/v5.1/companies(company_ID)/purchaseinvoices
Body = {
    /BuyFromVendorNo/: /MONNSU/,
    /DueDate/: /2023-06-06/,
    /DocumentDate/: /2023-06-05/,
    /VendorInvoiceNo/: /160392/,
### SOME MORE FIELDS
}
 
Response = 
{/error/:{/code/:/Internal_RecordNotFound/,/message/:/The Purchase Header does not exist. Identification fields and values: Document Type='Invoice',No.='' CorrelationId: d18af886-d80f-4970-9b11-e2e4f53623ab./}}
 
Tried several approaches:
1. verified the no series setup
2. created a purchase credit memo header successfully
3. verified no extensions other than mine works in the environment
 
Not sure what else can I try. please assist
I have the same question (0)
  • Suggested answer
    Community member Profile Picture
    2 on at
    Try removing unnecessary fields in the post request. After I cut it down to only documentType, buyFromVendorNo, payToVendorNo, vendorInvoiceNo I stopped getting this error.

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

News and Announcements

Season of Giving Solutions is Here!

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 > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,703

#2
YUN ZHU Profile Picture

YUN ZHU 803 Super User 2025 Season 2

#3
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 750 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans