Setting Customer Language Preference via SuiteScript

NetSuite Technical

Tags: , , ,

This article is relevant if you are creating contacts / customers in NetSuite via SuiteScript.

Background

For a recent client who elected to go with Magento eCommerce integrated with NetSuite’s ERP system, we developed a special NetSuite RESTlet service that will allow the Magento site to create customers in NetSuite.  The reason we do this is a part of a larger strategy where we draw customer and order information in Magento but the data comes from NetSuite in real-time (versus a more common approach to synchronize databases which forces other concerns to emerge — you know what I am talking about if you are synching data between Magento and NetSuite).

The Magento system is hosted in China designed for the Chinese public.  The NetSuite system is a One World account  where the default language preference is English. However, the customers will need to see their data in Chinese (Simplified).

Create Customers First / Edit to Set Language

The key thing to know is that you can’t set the language preference when you create the customer record.  Instead, you need to create the customer, reload it, then set the language.   Here is the code snippet.

// language not setting on created record – only edit is working

// create the customer record + set subsidiary + handle language preference
record = nlapiCreateRecord('customer');
record.setFieldValue('subsidiary', sub_id);
record.setFieldValue('isperson', 'T');
record.setFieldValue("lastname", "Magento"); // default a dummy value
record.setFieldValue("firstname", "Shopper");
var new_id = nlapiSubmitRecord(NS_record, false, false);

// reload record to set customer preference
record = nlapiLoadRecord('customer', new_id);
record.setFieldValue("lastname", "");
record.setFieldValue("firstname", "");
if (lang_id.length > 0){
	nlapiLogExecution('DEBUG', 'default lang', lang_id);
	record.setFieldValue('language', lang_id);
}

Related Articles

  1. NetSuite’s Locale Preference Lookup List

Innovate on NetSuite Platform

We love getting control over the NetSuite environment to realize its potential. If you would like to invent with NetSuite, contact us.

Be Sociable, Share!

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

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

3 thoughts on “Setting Customer Language Preference via SuiteScript

  1. Anish Duggal says:

    Hi Marty,

    I need to know where this variable ‘lang_id’ is coming from?
    I need to fetch internal ids of all languages in NetSuite which I’m not able to achieve.
    I’d really appreciate if you could help me.

    Best Regards,
    Anish Duggal

  2. Marty Zigman says:

    Anish,

    You will need to code the languages you want as a static list as discussed here:

    https://blog.prolecto.com/2013/11/18/netsuites-locale-preference-lookup-list/

    For lang_id in the code example, pass ‘us_EN’ for US English as provided in the article.

    Marty

Leave a Reply

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