Discussions
Join the NetSuite community to innovate, connect, and discover what’s next.
SuiteWorld brings thousands of innovators, builders, and leaders together to learn, connect, and shape what’s next. This October, explore how to build a stronger foundation for growth through inspiring keynotes, major product reveals, hands-on sessions, and unforgettable moments—all in one place for our biggest event of the year. Register now
Commit line using serverscripts
Help! Help!!
I have a serverscript to create a brand new invoice when an invoice fulfilling certain conditions is saved. I get the following error:
Script: invoiceAfterSave Error: USER_ERROR You must enter at least one line item for this transaction
I'm quite sure I'm missing the code to commit the new line - can anyone tell me what function to use for this?
Relevant portions of my code:
function invoiceAfterSave(type)
{
if (type.toLowerCase() == 'create')
{
var newRecord = nlapiGetNewRecord();
.....
var record = nlapiCreateRecord('invoice')
record.setFieldValue('entity', newRecord.getFieldValue('custbodybilling_customer'));
record.setFieldValue('location', 1);
nlapiSetLineItemValue('item', 'item', 1, "Servicing");
nlapiSetLineItemValue('item', 'quantity',1, 1);