Skip to Content
0

Service Layer: How to update, add and remove items for sales order

Jul 06, 2017 at 02:42 PM

373

avatar image

I’m currently using the service layer to test creating a sales order. Below is what I archive so far.

The next thing I’m trying to do is update item A00001, remove A00002 and add A00003. I know this can be done with the patch method and applying B1S-ReplaceCollectionsOnPatch equals to true to the header. Below is the header info set in Postman.

Below is the PATCH request I’m trying to make to update line number 0 and add item code A00003. However, I get an error as shown below. Would you know why this call didn’t work?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
William Grant Jul 11, 2017 at 05:47 PM
0

I found up why things didn't work. For LineNum 0 that I wanted to update, Service Layer wanted to know the item number. After I included the item number for LineNum 0, it did update this line with the new value, removed my second item A00002 and added a new item A00003. It woudl have been nice it would have been able to update LineNum 0 without referencing the item code.

Share
10 |10000 characters needed characters left characters exceeded
Ralph Oliveira
Jul 10, 2017 at 03:30 PM
0

The PATCH method requests that a set of changes described in the request entity be applied to the resource identified by the Request- URI. It's definition is righ here

So, whenever you try to make a PATCH, by definition, service layer will try to update the fields that are on your request. If a certain line is not there, it won't be deleted, but ignored.

To achieve what you want, use the PUT method. It will require the whole content of the Order object in the body, but will replace completely what you define on the DocumentLines array.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Oct 03, 2017 at 01:48 PM
0

Hi, I have the exact same requirement as explained here on SAP Business One v 9.2.

I tried using PUT method as well as PATCH method with 'B1S-ReplaceCollectionsOnPatch = true'. For both the scenarios I got the exact same error as shown below:

Fields LineNum, ItemCode, UoMCode, UoMEntry are all mentioned in the payload for every document line.

Could you please help.


so-error.png (21.5 kB)
Share
10 |10000 characters needed characters left characters exceeded