Using SuiteScript to Create Values for Existing Custom Segments
Your NetSuite account contains a custom record type for every custom segment that has been defined. To add a value to the custom segment, you add an instance of the corresponding custom record type.
You can find the internal ID of the appropriate custom record type on the custom segment definition, under the Record ID label.

For help working with this record in the UI, see Custom Segments.
Code Sample
The following sample shows how to create a value for a segment called Profit Center.
...
// Create new segment value
var newSegmentValue = record.create({
type: 'customrecord_cseg_profitcenter'
});
// Set a name value on segment value record
newSegmentValue.setValue ({
fieldId: 'name',
value: stItemIdValue
});
// If appropriate, you may want to set a parent value for the new value.
// For example, you might have a static value that you use for all
// segment values created through a script.
newSegmentValue.setText ({
fieldId: 'parent',
text: 'Created from automated script'
});
...