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 :
Business Central forum

Getting error while adding quantity in sales invoice lines through ODATA webservice using .NET

(0) ShareShare
ReportReport
Posted on by 10

Hi All,

I am using Odata web-service to Create Invoice.

I can create/delete Sales Invoices and SaleInvoiceSalesLines but without quantity and price

The moment i provide the quantity i get error saying "Property "Editable" for Quantity is invalid!" otherwise it creates the sales invoice and sales lines or items

=============================================================================

My code:

Dim uri As Uri = New Uri("myserver:7048/.../Company('CRONUS Canada, Inc.')")

Dim NAV As New productService.NAV(uri)
NAV.Credentials = New NetworkCredential("administrator", "password")

Dim Customer = New productService.mySaleInvoice
Customer.Sell_to_Customer_No = "21"

NAV2.AddTomySaleInvoice(Customer)
NAV2.SaveChanges()

Dim invLines = New productService.mySalesLines
invLines.Document_No = "1027"
invLines.Type = "Item"
invLines.No = "70061"
invLines.Description = "Sanjeev test"
invLines.Quantity = "1.0"
invLines.Unit_of_Measure_Code = "PCS"

invLines.Unit_Price = 50.0
NAV2.AddTomySalesLines(invLines)
NAV2.SaveChanges()

I have the same question (0)
  • Sanjeev Lal Profile Picture
    10 on at

    Anyone there with some suggestions??

  • Verified answer
    Charles Pockert Profile Picture
    30 on at

    I believe this is something to do with the conditional "editable" expression on the subform page. Basically, they added a condition where the quantity is not editable when the line is Type = Comment.

    These editable expressions seem to cause issues with webservices (OData/SOAP) in BC currently.

    The best workaround that I can think of is to re-create the pages you want to edit as an extension but that extension needs to omit the expression in the "editable" property.

    It should be trivial to do this, you probably only need access to several fields - plus since pages don't affect the schema you can push updates to your tenant without running into schema change issues in the case that you need to add more fields.

  • Suggested answer
    Suresh Kulla Profile Picture
    50,251 Super User 2025 Season 2 on at

    You need to make sure the Page you are using for the web services has the Editable Property true for that field.

  • Sanjeev Lal Profile Picture
    10 on at

    Where do we check that?

  • Verified answer
    Charles Pockert Profile Picture
    30 on at

    You'd have to modify the standard page using a page extension:

    docs.microsoft.com/.../devenv-page-ext-object

    But bear in mind, doing this will change the functionality so that a quantity can be entered on a comment line.

    I'd just re-create the entire page without any special functionality as a "web-service only" page and re-point the web service definition in Business Central to the new page.

    I don't agree with re-using standard pages as web services - I find it a very odd practice, like adding multiple concerns to viewmodels (re-using them for multiple pages) when writing MVVM applications then realising you have a bunch of spaghetti at the end.

  • Suggested answer
    Sanjeev Lal Profile Picture
    10 on at

    Thanks i fixed it.

    Had to edit the page itself as the license doesn't allow me to create new page.

  • Charles Pockert Profile Picture
    30 on at

    I assume we are talking on-prem business central? The only reason I'd do this as an extension instead of a page modification is that you will lose that functionality if you ever move to cloud (since IDE changes aren't supported with BC SaaS)

  • Sanjeev Lal Profile Picture
    10 on at

    Yes we are using on prem business central. Didn't had a choice now so had to do it. We are still in testing phase. Might upgrade licenses then will do it like an extention.

    Thanks for pointing out the correct way.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans