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.
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.