Matt R. Wilson
Matt R. Wilson

Reputation: 7575

What is the difference between `ID` and `Internal ID` for NetSuite records?

According to the help pop up:

ID

This field's value represents the script ID, used to identify this record for scripting purposes. It is a text field.

Internal ID

This field's value is a read-only system-generated unique identifier. It is an integer field.

Can anyone provide the reasoning behind having two identifiers and when to use one versus the other when scripting?

Upvotes: 2

Views: 6674

Answers (1)

erictgrubaugh
erictgrubaugh

Reputation: 8857

The major difference is that you (as the creator of a custom record or script) are in complete control of the text ID. You can establish patterns and best practices for defining these IDs, and it will make it very easy for developers to identify record types just by looking at the string ID. You have no control over the numeric ID. When looking at code, it is much easier for me to determine what records I am referring to if it looks like:

nlapiSearchRecord('customrecord_product', null, filters, columns);
nlapiResolveURL('SUITELET', 'customscript_sl_orderservice', 'customdeploy_sl_orderservice')

as opposed to looking at:

nlapiSearchRecord(118, null, filters, columns);
nlapiResolveURL('SUITELET', 13, 1)

I'm not even sure the second nlapiSearchRecord actually works, but I know that nlapiResolveURL can be written that way.

That said, if you simply let NetSuite generate the text ID, you'll end up with generic IDs like customrecord1, which I find no more useful than the numeric ID. It is a good practice to explicitly specify your own IDs.

Furthermore, the numeric ID can vary between environments (e.g. Sandbox could be different than Production, until a subsequent refresh occurs). If you are following good migration practices, then the text ID should never vary between environments, so your code would not have to make any kind of decision on which ID to use based on environment.

Rarely have I found myself referencing any record, whether native or custom, by its numeric ID; scripts are always using the text ID to reference a record type.

Upvotes: 2

Related Questions