Updating SalesOrder causes OrderDtls duplicate

I am updating Orders using the Epicor REST API (Erp.BO.SalesOrderSvc/SalesOrders('000',{OrderNum}))
Above is the endpoint I am using to update the order.

And below is the Payload I am sending

{
            "PONum": "xxxx",
            "email": "xx.buxxxss@xx.org",
            "Company": "000",
            "CustNum": 4,
            "OrderNum": 0,
            "OrderDate": "2023-03-22T07:40:18",
            "OTSPhoneNum": "",
            "OrderStatus": "pending",
            "ShipViaCode": "",
            "CurrencyCode": "USD",
            "CustomerName": "Cole xxx",
            "OrderComment": "",
            "EnableCreditCard": true,
            "BTContactPhoneNum": "",
            "ShipToAddressList": "US",
            "ShipToContactName": " ,",
            "SoldToAddressList": "US",
            "ShipToContactPhoneNum": "",
            "SoldToContactPhoneNum": "",
            "OrderDtls": [
                {
                    "Company": "xxx",
                    "PartNum": "xxxxx",
                    "OrderNum": 0,
                    "OrderLine": 1,
                    "UnitPrice": 1,
                    "DiscountPercent": 0,
                    "SellingQuantity": 1
                }
            ]
        }

Every time I update an order, even though it appears to be updating, it actually generates a new orderDtls instead of updating the existing one.

What should I do to change the orderDtls? ( like completely replace the current orderDtls with the new one coming)

I don’t see a rowmod field at all. I would try adding that and setting it to U.

Not seeing OrderNum to be updated either… 0 is new order

1 Like

I’m using ā€œ0ā€ as an illustration, but I’m passing the right OrderNum from the code.

are you passing in the right ordernum in both datatables? @Aliyu_Kamilu

I notice you have it 0 in the orderhed and the orderdtl data table in your json. You say you are updating the right OrderNum from the code, but are you updating it in BOTH places- in the orderhed and orderdtl tables in your JSON?

Yes, mate @utaylor , I updated them in both places.
BOTH the Orderdtl and Orderhed

@jkane
What’s the rowmod field supposed to do?
Let me see it when you add it please.

The RowMod tells the system you are U = ā€˜updating’ the data.
A=Adding
D=Deleting

2 Likes

Awesome @CSmith
I will try doing that and get back.