Marty Zigman Marty Zigman
Prolecto Labs Accelerator Templates

How to Distinguish a NetSuite Entity as a Customer vs. a Project

NetSuite Technical

Tags: , , ,

This article is relevant if you are a SuiteScript developer and you are working on a solution that needs to distinguish customers vs. project entities.

Background

In some recent work on our Distinguish NetSuite Sales as “New” vs. “Existing” solution, we needed some intelligence to distinguish between entities that are customers vs. projects.  This is easy to do if you have NetSuite’s SRP (Advanced Projects) module active because transaction records have two fields that are consistently applied:  Customer (entity) and Project (job).  However, if you are not using NetSuite’s SRP (Advanced Projects) module, and you want to use Projects to distinguish records, you only have one transaction entity field.  That entity can either be a Customer type or a Project type record.

We also wanted to know what the top level parent was for any sub structure.  NetSuite is sophisticated because it can express a hierarchy of customers and projects.  After some interrogation of the object model, we discovered some undocumented fields that can help in this endeavor.

SuiteScript Code Pattern to Determine Projects and Customers

The following code pattern was developed by one of our engineers after a session where she and I wanted to get a central function to help in our transaction work.

Customer/Project AfterSubmit Event

var entity = nlapiGetNewRecord();
var type = entity.getRecordType();
var parent = entity.getId();
if(type == ‘job’){
	parent = entity.getFieldValue(‘kcustomer’);  //undocumented
};
var s = nlapiSearchRecord('customer',null,
	new nlobjSearchFilter('internalid',null,'anyof',parent),
	new nlobjSearchColumn('internalid','toplevelparent')
);
if(s){
	var toplevelparent = s[0].getValue('internalid','toplevelparent');
};

Transaction AfterSubmit Event

//check entity record type
//leverage if the environment has NetSuite SRP (Advanced Projects) activated
var record = nlapiGetNewRecord();
var isadvance = nlapiGetContext().getFeature('ADVANCEDJOBS');
var entity = record.getFieldValue(‘entity’);
var recordtype = record.getRecordType();
var parent = entity;
if(!isadvance){
	recordtype = nlapiLookupField('customer',entity,'stage');
	if(recordtype == ‘JOB’){
		parent = nlapiLoadRecord(recordtype, entity).getFieldValue(‘kcustomer’);  //undocumented
	};
};

Grow your NetSuite Expertise

If you are a NetSuite programmer and you want to be appreciated for your capacity to produce innovations on the platform, perhaps we can work together. Our standards for quality are high and we care about ethics. Reach out to me and let’s talk about your ambitions.

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

4 thoughts on “How to Distinguish a NetSuite Entity as a Customer vs. a Project

  1. Corey Hunt says:

    Nice one Marty. I love the undocumented ones.

  2. Munzareen says:

    I m new on suitescript. I don’t know how to create our custom portal using netsuite and also don’t know the architecture of netsuite. Can anyone help me please.

  3. Marty Zigman says:

    Hello Munzareen,

    Have you seen the courses offered by NetSuite?

    https://www.netsuite.com/portal/services/training.shtml

    Also, NetSuite’s built-in Help document is pretty good. Generally though, we help our clients to solve platform challenges via a professional services relationship.

    Marty

Leave a Reply

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