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 :
Small and medium business | Business Central, N...
Suggested Answer

BC Get Operation on Sales Invoices Returning bad/wrong data via OData Protocol!

(0) ShareShare
ReportReport
Posted on by 959

As part of our migration to Business Central online I've been writing integration applications to import invoice data into BC.

This involves registering endpoints on Page 43 - Sales Invoice and Page 47 - Sales Invoice Lines.

When it comes to posting the invoices into BC everything is fine, but when it comes to getting or reading back the invoice data I've discovered the information cannot be trusted and/or is tainted. I initially thought I was the problem with how I was interacting with the OData endpoints, but then I realised if I copied the OData V4 URL into my browser the data it returned was also wrong, so it must be coming out of Business Central incorrectly.

To replicate the problem you first have to ensure that the Business Central tenant your using has more than one invoice listed. Then take the OData V4 URL for the Sales Invoice Lines and paste it into a browser tab. You'll be asked to authenticate and you should use the user name and API key registered for web services.

When the results come back in the browser and providing your list returns more than *one invoice*, use the browser search tool and search the field  [TotalSalesLine_Line_Amount] or [Total_VAT_Amount] or any field at the end of the Sales Invoice Lines for that matter. These fields should contain the line or document totals for Sales Invoices.

What we have discovered is these figures are wrong and always contain the value of the first invoice. These totals are replicated to all invoice lines even if you then filter the returning list to show only a single invoice.

It seems the only way to guarantee the document totals is to ensure only a single document is returned by the endpoint.

Can anybody confirm or deny our findings and suggest what's going on here. Is anybody able to communicate this to Microsoft?

Steve

I have the same question (0)
  • Suggested answer
    I Gusti Made Ari Profile Picture
    3,600 on at

    Please try to use the API for this case instead of publishing page as OData . The total field is calculated in the background when you open the page and this is calculated per document so it may not work the same when you use this as web services.

    https://docs.microsoft.com/en-us/dynamics-nav/api-reference/v1.0/api/dynamics_salesinvoice_get

    from above link you also can get the total from totalAmountIncludingTax field.

  • Steve Le Monnier Profile Picture
    959 on at

    Many thanks for your time responding, its much appreciated.

    I'm a little puzzled by the suggestion to use the API rather than the publishing page as OData. I'm not entirely sure I understand what you mean by this, as far as I'm concerned I am using the API, well that's what the tools I'm using should be doing when they hit up the published endpoint via the OData protocol.

    The explanation (about the behaviour) you suggest makes perfect sense as to what is going on, and the link provided is also interesting. The suggested example published only works because the request is asking for a single document! If I changed my request message on the OData endpoint to return one document only, the information that comes back will also be correct, but I need the list and not have to deal with looping the request.

    The problem I have and the issue I'm raising and seeking advice on; is how do you return a collection of invoices that doesn't mess up the totalsalesline_line_amount. Because it seems to me that you cannot pull this information out of BC via oDATA endpoints if it contains more than one invoice in the returning collection.

    Steve

  • Suggested answer
    Marco Mels Profile Picture
    on at

    Hello,

    We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist.  If you need assistance with debugging or coding I would recommend discussing this on one of our communities.

    www.yammer.com/dynamicsnavdev

    dynamicsuser.net/.../developers

    I will open this up to the community in case they have something to add.

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,092

#2
YUN ZHU Profile Picture

YUN ZHU 663 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 515

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans