Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Normalize a NetSuite entity ID to a valid customer internal ID reference using SuiteScript
// Author <>
// ensure that an entity ID is actually a customer ID
function retrieveCustomerId(entityId) {
var isAdvancedJobs = nlapiGetContext().getFeature('ADVANCEDJOBS');
var customerId = entityId;
if(!isAdvancedJobs) {
entityType = nlapiLookupField('customer', entityId, 'stage');
if(entityType == 'JOB'){
// undocumented `kcustomer`
customerId = nlapiLoadRecord(entityType, entityId).getFieldValue('kcustomer');
return customerId;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment