Discussions
Stay up-to-date with the latest news from NetSuite. You’ll be in the know about how to connect with peers and take your business to new heights at our virtual, in-person, on demand events, and much more.
New AI Community Guidelines. Please review and follow them to ensure AI use stays safe, accurate, and compliant.
Please note that on Saturday, April 11, 2026, at 8:00 PM Pacific time, our Case Management System will undergo a scheduled maintenance for approximately 30 minutes. During this time, case creation via SuiteAnswers will be unavailable and inbound calls will be routed to Customer Service.
Add Line Items to Sales Order (SuiteScript)
We are having a Thanksgiving sale and I need to create a script that will add free bonus items to our web store orders based on their order total. Here was my original script:
function SalesOrder_beforeSubmit(type) { // Execute this only when Sales order is created if (type == 'create') { // just report that the type is create nlapiLogExecution('DEBUG', 'type argument', 'type is create'); // Get the current record var currentRecord = nlapiGetNewRecord(); // Get the order total var total = parseInt(currentRecord.getFieldValue("total")); nlapiLogExecution('DEBUG', 'order total', total); // Get the number of line items before submit var lines = currentRecord.getLineItemCount('item'); nlapiLogExecution('DEBUG', 'number of line items', lines); // Add a new line item for the coin figures based on the order total if ( total > 299 ) { currentRecord.selectNewLineItem('item'); currentRecord.setCurrentLineItemValue('item', 'item', 33); currentRecord.setCurrentLineItemValue('item', 0