Marty Zigman - The NetSuite Expert

Conversations with Marty Zigman

Certified Administrator • ERP • SuiteCloud

Prolecto Labs Accelerator Templates

Guidelines For Working with NetSuite External IDs

Infrastructure NetSuite Technical



This article is relevant if you are working with NetSuite External IDs.

Background

NetSuite External ID (commonly referenced as externalid) is a means for creating a unique record ID independent of NetSuite’s auto-generated Internal ID (internalid). It is most commonly used when you seek to produce an integration between NetSuite and a third-party application.

Consider a Human Resource (HR) application that maintains important employee information.  Suppose that from within NetSuite, you would like to offer a way to hyperlink to the HR application. The external ID on the employee record can hold the HR record ID for the respective employee.  It then becomes simple to auto-generate the hyperlink that would transport the NetSuite user to the respective record in the HR application.

Important NetSuite External ID Guidelines

When using external IDs, often a number of questions emerge. Thus, this article helps a NetSuite administrator or developer quickly get oriented to the topic.

Here are key points to understand:

  1. Unique Values in Record Domains: external ID values are string-based and must be unique in their domain. Thus, external ID for entities (e.g. customers, vendors), transactions, and custom records must be unique. In my practice, we often prefix a unique ID with something about the respective interested application to help maintain uniqueness. In the example above, we would prefix values with “hr:”
  2. Not In Global Index: External IDs are not in the global search index.  You can look them up with saved-search.
  3. Exposing External ID: NetSuite’s form technology does not allow you to expose the External ID to the user. A quick workaround is to create an exposed custom field that sources its value dynamically from the external ID.  Another approach is to have a script-based dynamic field be added to the form view in the BeforeLoad event.
  4. Updating External ID: the most common referenced approach to update External ID is via CSV upload. Enough said.
  5. Script Updates on External ID: updating the external ID from a script is possible. However, there are some considerations: a) you can’t update it from the target record’s BeforeSubmit operation — it must be from the AfterSubmit; and b) scripts to create or update a record can set the externalid like any other field operation.  See below for a code pattern.
  6. Unsupported External ID Record Types: NetSuite provides a reference to field types that do not support External ID, see this SuiteAnswers article.  At the time of this writing, these record types are not supported: Accounting Period, Budget Category, CRM Custom Field, Currency Rate, Custom List, Custom Record Custom Field, Custom Record Type, Entity Custom Field, Gift Certificate, Item Custom Field, Item Number Custom Field, Item Option Custom Field, Landed Cost, Other Custom Field, State, Transaction Body Custom Field, and Transaction Column Custom Field.

Setting NetSuite External ID to Null

You may need to set the External ID to null — the default state. This must be done in a script. Thus, the following Mass Update SuiteScript 2.x code pattern can be used. This code pattern can easily be adapted for other External ID operations:

// SEE ADDENDUM BELOW ==== THIS CODE PATTERN DOES NOT SET TO NULL EXTERNAL IDS
define(['N/record'],
	function(record) {
		function each(params) {
			var funcName = "PRI_MU_SetExtID_Null " + params.type + " " + params.id;
			try {
				var r = record.load({type: params.type, id: params.id, isDynamic: true})
				log.debug(funcName, r.getValue({fieldId: 'externalid'}))
				r.setValue({
					fieldId: 'externalid',
					value: null,
					ignoreFieldChange: true
				});
				r.save({ignoreMandatoryFields: true});
				log.debug(funcName, "Record Loaded/ExtID Null/Saved");
			} catch (e) {
				log.error(funcName + " error", e);
			}								
		}
		return {
			each: each
		};
	}
);

Addendum to Script for Setting ExternalID to Null

Further research indicates that SuiteScript 2.0 has challenges setting external ID to Null.   This SuiteScript 1.0 code pattern has been offered up as an approach:

var recordId = '123';
var recordType = 'customrecord1';
var record = nlapiLoadRecord(recordType, recordId);
record.setFieldValue('externalid', '');
nlapiSubmitRecord(record);

I need to perform more testing to confirm the SuiteScript 1.0 pattern above indeed will nullify the externalid.

NetSuite External ID Summary

I like the idea of External IDs primarily because they enforce uniqueness without having to do work for that feature.  Yet, it is important to plan when using them — thus the idea of using a prefix to ensure uniqueness helps to plan for unknown application situations long term.

If you found this article relevant, feel free to sign up for notifications to new articles as I post them. If you would like to work with NetSuite experts dedicated to their craft, 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

12 thoughts on “Guidelines For Working with NetSuite External IDs

  1. Mike Robbins says:

    Hi, Marty. I created a mass update script with your example and deployed it against the Account and Customer record types and it does not seem to clear the external id field.

    Is there a setting or feature that needs to be enabled to be able to null external id fields?

  2. Marty Zigman says:

    Hi Mike,

    Shoot, I believe you are right. It may not be possible to do this in an SS2.0 pattern. But there is some information (via Google) that it could be done in SS 1.0. I suspect this article is misleading so I am posting an update.

    Marty

  3. Brett says:

    Hi Marty,

    I’ve just tested this with both SuiteScript 1.0 and 2.0 and none of these options seem to be able to set the External ID field to Null.

    So it looks like that there currently is no solution for this.

    Cheers
    Brett

  4. Marty Zigman says:

    Thank you Brett for the follow up.

    Marty

  5. C.J. says:

    Typo on the page. You have “BeforeSumbit” and I believe you meant “BeforeSubmit”

  6. Marty Zigman says:

    Thank you! I have updated the article.

    Marty

  7. Thorne Perun says:

    Have you ever seen a script that auto-generates a unique external ID? Or does the accounting team just have to keep track of which external IDs they have used in the past?

  8. Marty Zigman says:

    Hello Thorne,

    Yes, we have a script that will automatically generate an External ID based on the value of another field. Contact us at https://www.prolecto.com/services/innovations/ and we can help get this set up for you.

    Marty

  9. Anand says:

    Hi Marty,

    Is there a way through SS2.0 where we can retrieve items with their external id instead of their internal id while adding new sales order?

  10. Marty Zigman says:

    Hello Anand,

    There is no reason why you should not be able to retrieve a record by an external ID. Can you provide more information?

    Marty

  11. Pushpa says:

    Hi Marty,

    I have created external id as a custom field in NetSuite customer form, but when I upload any upload any customer the external id is not getting updated.

    Can you help me on this

  12. Marty Zigman says:

    External IDs do not get updated via the form. You need to work with script and/or references in this article.

    Marty

Leave a Reply

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