Marty Zigman

Conversations with Marty Zigman

Certified Administrator • ERP • SuiteCloud

Set NetSuite Line Defaults on Item Fulfillments

NetSuite Technical

Tags: , , ,

This article is valuable if you are using SuiteScript and you are trying to set defaults on line values with an item fulfillment.

Background

For a recent client implementation, we needed a mechanism to specify the country as part of the item fulfillment at each line level.  Because this client is in the media business, they wanted to track the number of user actions that their media produced by country of origin.  Naturally, the thought was to create a custom transaction column of type list / record and link it out to the built-in NetSuite country list.  Most of the traffic would come from the United States.  So we wanted this country to be the default when the item fulfillment record loaded. Yet, with all the typical ways to set defaults on transaction column fields, the conventional way would not work.  The strange thing is that if we placed this custom transaction column field on a Sales Order, it acted as expected.

Indeed, it does seem that the item fulfillment behaves different from other transaction types.  Thus the need for more inspection, diagnosis and ultimately, resolution.

Solving the Item Fulfillment Default Value Challenge via Client Side SuiteScript

It’s important to remember that the NetSuite UI is HTML.  This means we have an opportunity to view the page source and inspect scripts and structure.  When doing this, we noticed that our custom field had another related field with a suffix called “_display”.  We learned that we had to set the conventional custom field and the related _display one with the values we needed.  Below is the client side code pattern we used.

function prd02_clientPageInit() {

	var COUNTRY_CODE_UNITED_STATES = 230;
	var COUNTRY_NAME_UNITED_STATES = "United States";

	// On an item fulfillment, you need to set both the field and the "_display" extension
	// otherwise it won't default properly!

	//confirm that we are in create mode; we expect no record ID
	if (!nlapiGetRecordId())
		for (var i = 1; i <= nlapiGetLineItemCount("item"); i++) {
			nlapiSetLineItemValue("item", "custcol_prolecto_fulfillment_country", i, COUNTRY_CODE_UNITED_STATES);
			nlapiSetLineItemValue("item", "custcol_prolecto_fulfillment_country_display", i, COUNTRY_NAME_UNITED_STATES);
		}
}

Enhance Your NetSuite Account

Should you find that you need to extend NetSuite beyond the conventional approaches, or people tell you, “that can’t be done”,  let’s have a conversation.  We are NetSuite experts and our core competency is innovating on the platform.

Marty Zigman LinkedIn

Marty Zigman

Holding three official certifications, Marty is widely recognized as a top NetSuite expert and leads a team of senior professionals at Prolecto Resources, Inc. A former Deloitte & Touche CPA and technology executive with CTO roles, he brings over 35 years of leadership in ERP, CRM, and eCommerce business systems. Contact Marty to engage directly.

BiographyYouTubeLinkedInX (Twitter)

4 thoughts on “Set NetSuite Line Defaults on Item Fulfillments

  1. The main problem that generates this problem is the behavior of the nlapiSetLineItemValue against the nlapiSetCurrenLineItemValue which is why you have to set the _display field too.
    The “Current” version manipulates better the information display on the edited lines, the problem sometimes is, with Item Fulfillments and Item Receipts that you don’t actually edit lines as with everyother transaction.

    Reply
  2. I used a bit of that code to try and source the values of a custom column into the “PO Rate column. So far it hasn’t thrown any errors but I still can’t get it to work.
    This is what I have so far, any advice would be greatly appreciated.

    function porrateclientPageInit()
    if (!nlapiGetRecordId())
    for (var i = 1; i <= nlapiGetLineItemCount("item"); i++) {
    var pocost = nlapiGetLineItemValue("item", "custcol_po_cost")
    nlapiSetLineItemValue("item", "porate", i, "pocost");
    }
    }

    Reply

Leave a Reply

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