Marty Zigman Marty Zigman
Prolecto Labs Accelerator Templates

Tip: Adding SuiteScript 2.0 Lines on NetSuite Transactions

NetSuite Technical



This article is relevant if you are using SuiteScript 2.0 to enhance NetSuite to add line items to a sales order or other transactions.

Background

During a recent implementation of a custom shipping calculator for a client, our senior technical analyst, Elie C., was working to build a client-side enhancement that would move shipping rate information from NetSuite’s standard header to a transaction line.   Elie’s algorithm was working perfectly server-side but was not working client-side.  While working in the browser console, he was unable to add a new line and commit values.

As a member of the Prolecto team, Elie C. reached out to our technology-oriented group and was offered a technical tip from another senior technical analyst, Boban B.   I surmised that this tip would help save time for the larger NetSuite development community.

Use FireSlavingSync on Sublist Values

The trick to solve Elie’s challenge was to set fireSlavingSync equal to true.  By default, the value is false.  The attribute triggers other dependent values on the record machine to “sync up” and thus behave the way you expect it to.

NetSuite offered this SuiteAnswers ID 29093 with a code example. See the excerpt below:

function pageInit(context) {
	var currentRecord = context.currentRecord;
	currentRecord.selectLine({
		sublistId: 'item',
		line: 0
	})
	currentRecord.setCurrentSublistValue({
		sublistId: 'item',
		fieldId: 'item',
		value: 5,
		fireSlavingSync: true
	})
	currentRecord.commitLine({
		sublistId: 'item'
	})
	
	currentRecord.selectNewLine({
		sublistId: 'item'
	})
	currentRecord.setCurrentSublistValue({
		sublistId: 'item',
		fieldId: 'item',
		value: 6,
		fireSlavingSync: true
	})
	currentRecord.commitLine({
		sublistId: 'item'
	})
}

Work with an Accomplished NetSuite Development Team

NetSuite created a great business platform — it’s robust and configurable without requiring learning formal software development.  However, the ability to unlock greater potential lies in the programming capacity through the use of JavaScript-based SuiteScript programming.  Our team of professionals holds high standards for excellence and care.  We regularly discuss the merits of learning, being curious, and reaching out to others when you need help.  We say “yes” when others say “no”.

If you found this write-up helpful, feel free to receive notifications as I publish new articles.

Perhaps you are not recognized for your creative abilities and would like to work with a team of accomplished professionals.  If you are ready to advance your career, let’s have a conversation.

Marty Zigman

Holding all three official certifications, Marty is regarded as the top NetSuite expert and leads a team of senior professionals at Prolecto Resources, Inc. He is a former Deloitte & Touche CPA and has held CTO roles. For over 30 years, Marty has produced leadership in ERP, CRM and eCommerce business systems. Contact Marty to set up a conversation.

More Posts - Website - Twitter - Facebook - LinkedIn - YouTube

About Marty Zigman

Marty Zigman

Holding all three official certifications, Marty is regarded as the top NetSuite expert and leads a team of senior professionals at Prolecto Resources, Inc. He is a former Deloitte & Touche CPA and has held CTO roles. For over 30 years, Marty has produced leadership in ERP, CRM and eCommerce business systems. Contact Marty to set up a conversation.

Biography • Website • X (Twitter) • Facebook • LinkedIn • YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *