Discussions
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);