Reputation: 1130
I need to be able to upsert line items in a NetSuite invoice with updated information from an external system.
I am creating an invoice in NetSuite with the payload:
{
"tranDate": "2021-07-12",
"dueDate": "2021-07-19",
"externalId": "sysA_INV-34698",
"amountPaid": 0,
"entity": {
"id": 3127
},
"item": {
"items": [
{
"item": {
"id": 374
},
"internalId": "sysA_INV-34698_JOBID-4875398"
"quantity": 1,
"rate": 534.54
}
]
}
}
I would like to upsert this line item using the internalId but it doesn't appear to be saved against the line item, therefore I cannot target it. Is it possible in NetSuite to upsert/update a line item, or do I have to remove them all and recreate them every time there is new data from the source system?
Upvotes: 0
Views: 1328
Reputation: 15926
To update a specific line item, use the item.items.line
field. That will let you target a specific line for updates.
Upvotes: 1
Reputation: 451
It's not the same as an upsert, but this at least can get it done in one call, assuming you always know the previous items.
With the NetSuite REST API you can overwrite the items without appending by submitting a PATCH
request with parameters replaceSelectedFields=true
and replace=item
Thus your request url might look like
PATCH .../invoice/{id}?replaceSelectedFields=true&replace=item
Upvotes: 0