I have a scenario like this: System A creates invoices with line items and pushes into NetSuite. It's possible, later, the invoice in System A has been modified where line items are either updated or removed and pushed back into NetSuite. How would we know what line items have been modified or removed? Should System A send back a line id? In that case I am trying to work out how to obtain line item Id but it's not returning a value.
for (var x = 1; x <= itemcount; x++)
{
var lineid = nlapiGetLineItemValue('item', 'linenumber', x)
nlapiLogExecution('DEBUG', 'removing = ', lineid);
if(lineid == 1)
{
nlapiLogExecution('DEBUG', 'removing line item 1');
nlapiRemoveLineItem('item', x)
}
}
I have a scenario like this: System A creates invoices with line items and pushes into NetSuite. It's possible, later, the invoice in System A has been modified where line items are either updated or removed and pushed back into NetSuite. How would we know what line items have been modified or removed? Should System A send back a line id? In that case I am trying to work out how to obtain line item Id but it's not returning a value.
for (var x = 1; x <= itemcount; x++)
{
var lineid = nlapiGetLineItemValue('item', 'linenumber', x)
nlapiLogExecution('DEBUG', 'removing = ', lineid);
if(lineid == 1)
{
nlapiLogExecution('DEBUG', 'removing line item 1');
nlapiRemoveLineItem('item', x)
}
}
Share
Improve this question
edited Sep 11, 2020 at 22:36
quarks
35.4k82 gold badges308 silver badges546 bronze badges
asked Apr 5, 2016 at 15:55
MG2016MG2016
31910 silver badges34 bronze badges
2 Answers
Reset to default 3The approach with a custom transaction column field is a good thing to deal with the sync of data between NS and to an external system with RESTlet. But we have a inbuilt option to perform this and that is the standard way of doing it.
ExternalId is a standard column that is available for records and lineitems, Where this can be used to update / remove lineitems on a record.
This ExternalId cannot be viewable in UI of NS records. This can be stored the with recordid that stored in the external system.
For an example, External System with SQL table stores a SalesOrder and it has an id column in that table and also the SOLineItem table stores the respective lineitem of salesorder also contains the identity column.
Now the record id has to be passed to JSON as externalid for the SO and the lineitems id has to be passed to JSON as externalid for lineitems under items object in JSON.
Sample JSON
{
"internalid": "",
"recordtype": "salesorder",
"entity": "3217",
"salesrep": "3209",
"terms": "2",
"trandate": "6\/16\/2014",
"orderstatus": "A",
"otherrefnum": "245852",
"billaddress":"",
"shipaddress":"",
"externalid": "FF160614-SO03", //ID of SO record on SO SQL table
"item": [
{
"isremove":"",
"internalid": "",
"item": "486",
"amount": "50",
"quantity": "5",
"externalid": "FF160614-SO03-L1-INV-486" //ID of LineItems record SOLineItem SQL table
},
{
"isremove":"",
"internalid": "",
"item": "700",
"amount": "100",
"quantity": "1",
"externalid": "FF160614-SO03-L2-GRP-700A" //ID of LineItems record SOLineItem SQL table
}
]
}
If you noticed the sample JSON where it have a property called isremove in item sublist. If that set to true the respective line item has to be removed.
We have not found any of NetSuite's linenumber
or other such fields to be a reliable way of identifying a line item. They seem to change throughout the life of the record whenever the lines are reordered or modified.
We have acplished this in the past by adding a custom Transaction Column field called something like Unique ID or Line ID or whatever you wish. Then, either NetSuite or the external system can generate a UUID for each line and store it in the custom column. So long as both systems maintain a reference to the UUID for each line, you can keep them in sync.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745180375a4615390.html
评论列表(0条)