Discussions
Join us for complimentary one-day events around the world and step into a future fueled by AI and limitless potential. Explore new breakthroughs, sharpen your skills, and connect with experts who are shaping what’s next. Experience bold keynotes, interactive learning, and connections that span the global NetSuite community. Discover what's next at SuiteConnect Tour 2026.
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);