Skip to main content
Community site session details

Community site session details

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

Web service: Add line to PO

(0) ShareShare
ReportReport
Posted on by

I'm trying to add a new purch line to an existing purchase order via the web services. I've gone through the list of available services and tried quite a few of them, to no avail. The one that makes the most sense would be Page 54, "Lines", as that is the purchase lines page.

I tried sending the Document Nbr of the PO I want to add the line to, but receive the following error message: "Field Document No. is readonly!"

However if I don't include it, I get an error saying the Document No is required!

This happened with a few of the "Lines" pages when I tried them as well. 

Does anyone know how to add a new line to an existing purchase order via the web services?

  • Suggested answer
    keoma Profile Picture
    32,727 on at
    RE: Web service: Add line to PO

    the logic of the keys is not known. not sure why you need that.

    as i wrote you can use the read(key) function or the readmultiple(filter...) function.  with the needed filter settings you get the wanted records.

    for usage of the readmultiple fct. goto docs.microsoft.com/.../readmultiple-operation

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Web service: Add line to PO

    The solution we came up with is to regularly sync the keys to a table in our database using the ReadMultiple service, so we have the unique key for the existing purchase order headers. We can then use that key in Update or UpdateMultiple to add a line. In proof of concept testing, this seems to work.

    It would be much better if we didn't have to sync the keys in this manner but could create them instead. However per my last comment, the Purchase Order key is a combination of the simple key Franz mentioned and every single line's key, which means it changes and cannot be calculated in any reasonable manner

  • Community Member Profile Picture
    on at
    RE: Web service: Add line to PO

    When I do a read the key value is "32;JgAAAACLAQAAAAJ7BjEAMAA2ADAAMAAx6;7908161;10;PurchLines4;44;JwAAAACLAQAAAAJ7BjEAMAA2ADAAMAAxAAAAAIcQJw==6;7908180;44;JwAAAACLAQAAAAJ7BjEAMAA2ADAAMAAxAAAAAIcgTg==6;7928780;44;JwAAAACLAQAAAAJ7BjEAMAA2ADAAMAAxAAAAAIcwdQ==6;8242710;44;JwAAAACLAQAAAAJ7BjEAMAA2ADAAMAAxAAAAAIdAnA==6;8242780;"

    It is appending the line's key for each line too. This doesn't seem like the "document type","document no." key that you mention. What am I missing here?

  • Suggested answer
    keoma Profile Picture
    32,727 on at
    RE: Web service: Add line to PO

    as i wrote the standard way is loading the PO in the client app via webservice using the read(key) function. the key is always the primary key of the table, for the PO it is "document type","document no.". then add a new line using the lines property. the GetRecIdFromKey function is not the best idea to get a record, because the needed key is not available.

    other solutions need customizations, e.g. setting the fields document type, document no. in page 54 to editable

    or use page 518 and set the whole page to editable.

  • Community Member Profile Picture
    on at
    RE: Web service: Add line to PO

    We're looking for a solution that would not require customizing Business Central at all. Are you saying then that this is not possible with the existing web services?

  • Suggested answer
    keoma Profile Picture
    32,727 on at
    RE: Web service: Add line to PO

    then create a query based on table purchase line, add only the needed fields.

    publish the query and use in your client app.

  • Community Member Profile Picture
    on at
    RE: Web service: Add line to PO

    Franz, that was the first approach we tried but we won't have the key available, so we want to update based solely on the PO Number

  • Community Member Profile Picture
    on at
    RE: Web service: Add line to PO

    Ideally I'd like to use standard pages/services as this is part of an ISV solution and we don't want to ask the customer to customize their environment directly

  • Suggested answer
    keoma Profile Picture
    32,727 on at
    RE: Web service: Add line to PO

    you can work with the published purchase order page. the webservice has then a lines property, where you can add your line and update/save the PO.

  • Community Member Profile Picture
    on at
    RE: Web service: Add line to PO

    The field is read only in the Page 54. That's why you can't update it from Web Service.

    Out of the box BC API only have Purchase Invoice. I think you have few options:

    1. Add another "Document No." field in page 54 and make it editable but not visible

    2. Create new API page based on existing Purchase Invoice lines API

    docs.microsoft.com/.../dynamics_purchaseinvoiceline

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

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 2,655

#2
Mansi Soni Profile Picture

Mansi Soni 1,574

#3
YUN ZHU Profile Picture

YUN ZHU 1,453 Super User 2025 Season 1

Featured topics

Product updates

Dynamics 365 release plans