Published on July 4, 2022.
By default, NetSuite accounts are setup with classifications that include class, department, and location. However, NetSuite also supports additional custom classifications, and these are known as Custom Segments. You can setup as many custom segments as you'd like, define the values that are appropriate for each segment, and specify the types of records that each segment applies to. In addition, you can indicate if a segment should be included on GL Impact pages, and segments can be used as filters and columns on NetSuite reports. Very few of my clients use Custom Segments, but those that do have found them to be quite helpful.
I occasionally get questions from other NetSuite developers asking about Custom Segments and how they can be used in SuiteQL queries. In this post, I'm going to share a few queries that I think will help answer those types of questions.
It's important to note that Custom Segments is a NetSuite feature that is disabled by default. If the feature isn't enabled, then the queries below will not work. In fact, if you run these queries without the feature being enabled, you'll likely get errors such as "Search error occurred: Record 'CustomSegment' was not found." The reason is that the tables used by the Custom Segments aren't created unless the feature is enabled.
One more note: Custom Segments are very flexible and can be used in many different ways. For example, you can setup a hierarchy of custom segment values, filter them by Class, Department, Location - and in OneWorld accounts, by Subsidiary. In the examples below, I'm using a very simple implementation of a Custom Segment, with no value hierarchy or filtering. It's also possible to setup a Custom Segment as either a List/Record type, or as a Multiple Select type. In the examples below, I'm using a segment that has been configured as a List/Record type.
When you create a Custom Segment, a record is added to the CustomSegment table. Querying this table will reveal the ScriptID that has been assigned to the segment, as well as the ID of the record type (the "Custom Record Definition") that has been created.
For example:
SELECT * FROM CustomSegment
The result looks like this.
Click the image to view a larger version.
As you can see, the account has a single custom segment, Region. Also note that the segment has been assigned a custom record type with ID 652.
We can get more information about the custom segment by querying the CustomRecordType for the custom record ID that the segment has been assigned. Continuing with the example above:
SELECT * FROM CustomRecordType WHERE InternalID = 652
The result looks like this.
Click the image to view a larger version.
You can join the CustomSegment and CustomRecordType tables to easily get a list of all custom segments and their table names.
SELECT CustomSegment.Name AS CustomSegmentName, CustomRecordType.ScriptID AS CustomSegmentTableName, CustomSegment.GLImpact FROM CustomSegment INNER JOIN CustomRecordType ON ( CustomRecordType.InternalID = CustomSegment.RecordType ) WHERE ( CustomSegment.IsInactive = 'F' ) ORDER BY CustomSegment.Name
That query is included in the SuiteQL Query Tool's Remote Library. Just search for "custom segments."
The CustomRecordType's ScriptID value is actually the name of the table that holds a custom segment's values. In the example above, the ScriptID that was assigned to the "Region" custom segment is CUSTOMRECORD_CSEG_REGION. So, to get the segment's values, we can simply query the table like this.
SELECT * FROM CUSTOMRECORD_CSEG_REGION
And the result looks like this.
Click the image to view a larger version.
In my example, I've applied the "Region" custom segment to the Employee table, and assigned a region to a few employees. The following query shows how I can query the Employee table and reference the custom segment column.
SELECT ID, LastName, FirstName, Phone, Email, CSeg_Region, BUILTIN.DF( CSeg_Region ) FROM Employee WHERE ( Email LIKE '%@test.com' ) AND ( CSeg_Region IS NOT NULL ) ORDER BY LastName, FirstName
The query result looks like this.
Click the image to view a larger version.
Notice the use of the BUILTIN.DF function on the CSeg_Region column, which returns the custom segment value. You can also join to the custom segment's table, like this.
SELECT Employee.ID, Employee.LastName, Employee.FirstName, Employee.Phone, Employee.Email, Employee.CSeg_Region, CUSTOMRECORD_CSEG_REGION.Name AS RegionName FROM Employee INNER JOIN CUSTOMRECORD_CSEG_REGION ON ( CUSTOMRECORD_CSEG_REGION.RecordID = Employee.CSeg_Region ) WHERE ( Employee.Email LIKE '%@test.com' ) AND ( Employee.CSeg_Region IS NOT NULL ) ORDER BY Employee.LastName, Employee.FirstName
As I mentioned above, Custom Segments can be quite helpful, and they are very flexible, too. In this short blog post, I've shared a few queries that I hope will help you should you ever need to work with Custom Segments.
Hello, I'm Tim Dietrich. I develop custom software for businesses that are running on NetSuite, including mobile apps, Web portals, Web APIs, and more.
I'm the developer of several popular NetSuite open source solutions, including the SuiteQL Query Tool, SuiteAPI, and more.
I founded SuiteStep, a NetSuite development studio, to provide custom software and AI solutions - and continue pushing the boundaries of what's possible on the NetSuite platform.
Copyright © 2025 Tim Dietrich.