Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

Failure on creating purchase invoice header from custom extension page

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
  • Suggested answer
    Failure on creating purchase invoice header from custom extension page
    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

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,228 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,056 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans