Learn SuiteScript 2.0 Pattern to Update NetSuite Item Vendor Purchase Price List

This article is relevant if you seek to understand how to program NetSuite’s vendor purchase price list on the item record.


In the article Maintain NetSuite Foreign Currency Item Purchase Price Lists I illustrate how to maintain a NetSuite purchase price list using native and custom structures. One of our clients sought a mechanism to update NetSuite’s native vendor purchase price list using some techniques that required script. The price list can be maintained in different currencies. Since it was not documented well, one our senior consultants brought forth the code pattern. I bring it here to you.

NetSuite SuiteScript 2.0 to Update Vendor Item Price List

Below is the basic and simple SuiteScript 2.0 script to help illustrate the pattern to read and update the vendor item purchase price list. See related image for an example of the vendor item list we are updating.

 * @NApiVersion 2.x
 * @NScriptType UserEventScript
 * @NModuleScope SameAccount
define(['N/record', 'N/search'],
 * @param {record} record
 * @param {search} search
function(record, search) {
     * Function definition to illustrate how to update the currency price list offered by a vendor.
	function beforeLoad(scriptContext) {
		//for learning, hard code loading the item we are working with
		var itemRecord = record.load({type: record.Type.INVENTORY_ITEM, id: 501});

		//get the item's vendor price sublist
		var sublistRecord = itemRecord.getSublistSubrecord({
			sublistId: 'itemvendor',
			fieldId: 'itemvendorprice',
			line: 0
		//spin through the sublist of prices; arbitrarily update the price to illustrate how
		var count = sublistRecord.getLineCount({sublistId: 'itemvendorpricelines'});
		for ( var i=0; i < count ; i++)
			var id = sublistRecord.getSublistValue({sublistId: 'itemvendorpricelines', fieldId: 'id', line: i});
			var vendorcurrency = sublistRecord.getSublistValue({sublistId: 'itemvendorpricelines', fieldId: 'vendorcurrency', line: i});
			var vendorcurrencytext = sublistRecord.getSublistText({sublistId: 'itemvendorpricelines', fieldId: 'vendorcurrency', line: i});
			var vendorprice = sublistRecord.getSublistValue({sublistId: 'itemvendorpricelines', fieldId: 'vendorprice', line: i});

			log.debug(id + vendorcurrency + vendorcurrencytext, vendorprice);

			sublistRecord.setSublistValue({sublistId: 'itemvendorpricelines', fieldId: 'vendorprice', line: i, value: (i+1)*1000});

		//commit the item record.  The sublist will update

    return {
        beforeLoad: beforeLoad,

NetSuite Enhancement Support

NetSuite’s platform is designed to be enhanced to meet operational business requirements. If you are looking to be part of a team of professionals that appreciate innovation, technology, and leadership, let’s have a conversation.

Be Sociable, Share!

Marty Zigman

Holding all three official certifications, Marty is Southern California's 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 25 years, Marty has produced leadership in ERP, CRM and eCommerce business systems. Contact Marty to setup a conversation.

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

| Tags: , , | Category: NetSuite, Technical | Leave a comment

Post a Comment

Your email is never published nor shared. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>