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
nlobjRecord.insertLineItem issues
I've been trying to insert a line item (insurance cost) after the user clicks on Save on a transaction. First, I did it with a client script, but the sync issues were too constricting. So I then moved to a User Event script (beforeSubmit). Here is the code:
function beforeSubmit() {
addInsuranceLine();
}
function addInsuranceLine() {
var record = nlapiGetNewRecord();
record.insertLineItem('item', record.getLineItemCount('item'));
record.setLineItemValue('item', 'item', record.getLineItemCount('item'), 21);
record.setLineItemValue('item', 'quantity', record.getLineItemCount('item'), 1);
record.setLineItemValue('item','rate', record.getLineItemCount('item'), 0.01);
record.setLineItemValue('item','amount', record.getLineItemCount('item'), 0.01);
}
Note that 21 is the internal ID of the item I want to add.