Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Answered

Error occurring creating invoice when assigning a value to globalDimension1Code

Posted on by 20

I'm getting the following error when trying to assign a value to globalDimension1Code on an invoice create. The create works fine when that field is omitted but I need the value to be assigned (it's connected to the BU in the app).

status: 404
message: {"error":{"code":"Internal_RecordNotFound","message":"The Sales Header does not exist. Identification fields and values: Document Type='Invoice',No.='115055515'  CorrelationId:  433de58d-1663-4934-a8a4-49e38754dc21."}}

I'm posting to this URL for the invoice create:

api.businesscentral.dynamics.com/.../salesInvoices

This is content of my invoice:

{
  "number": "115055515",
  "invoiceDate": "2023-03-08",
  "customerId": "7e2759a8-37bd-ed11-9a88-000d3a363d43",
  "dueDate": "2023-04-22",
  "externalDocumentNumber": "7674307",
  "shortcutDimension1Code": "10"
}



  • Suggested answer
    Bilal Haider Profile Picture
    Bilal Haider 45 on at
    RE: Error occurring creating invoice when assigning a value to globalDimension1Code

    Hi,

    One solution of this problem is that you insert Sales Invoice without shortcutDimension1Code and get id and if-Match (etag) of inserted document from response.

    pastedimage1678303370290v1.png

    Then send another Patch request by appending that id in URL as api.businesscentral.dynamics.com/.../salesInvoices(id of inserted invoice) and using If-Match (available in response) parameter and body like

    {

     "shortcutDimension1Code": "ADM"

    }

    Other way is to use deep insert.

  • Pat Arneson Profile Picture
    Pat Arneson 20 on at
    RE: Error occurring creating invoice when assigning a value to globalDimension1Code

    I realized I put the wrong thing in the subject of my post, it's shortcutDimension1Code, not globalDimension1Code. I copied that out of my code during a test before I changed it back to shortcutDimension1Code.

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 Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans