Discussions
Stay up-to-date with the latest news from NetSuite. You’ll be in the know about how to connect with peers and take your business to new heights at our virtual, in-person, on demand events, and much more.
Now is the time to ask your NetSuite-savvy friends and colleagues to join the NetSuite Support Community! Refer now! Click here to watch and learn more!
Creating Inventory Adjustments: Add a line item
I am doing some exploratory work on whether or not we can automate some inventory transfers for a demo program that we have. I am trying to create an Inventory Adjustment record that subtracts inventory from one warehouse and adds it to another. Everything seems to work just fine in how the nlobjRecord is manipulated, but when I submit it I keep getting the following error:
UNEXPECTED_ERROR: You must enter at least one line item for this transaction.
The code that generates this error follows:
function testAdjCreate() { try { var existing = nlapiLoadRecord("inventoryadjustment", "67071"); var xfer = nlapiCreateRecord("inventoryadjustment"); xfer.setFieldValue("account", "305"); xfer.setFieldValue("adjlocation", "4"); xfer.setFieldValue("haslines", "T"); xfer.setLineItemValue("inventory", "item", 1, 768); xfer.setLineItemValue("inventory", "location", 1, 5); xfer.setLineItemValue("inventory", "adjustqtyby", 1, 5); xfer.setLineItemValue("inventory", "item", 2, 768); xfer.setLineItemValue("inventory", "location", 2, 4); xfer.setLineItemValue("inventory", "adjustqtyby", 2, -5); var count = xfer.getLineItemCount("inventory"); var id = nlapiSubmitRecord(xfer, true); } catch (err) { alert (err.getCode() + ":n" + err.getDetails()); } } 0