This article is relevant if you are programming NetSuite SuiteScript against custom segments.
Background
In our Systems Integration Practice, since we started working with NetSuite in 2008, we heavily utilize NetSuite Timesheets. As our firm developed specialized practice areas, we extended the database to utilize custom segments.
In 2012, well before the advent of SuiteScript 2.x, we built an “Enterprise Timesheet Manager” to help extend the NetSuite Timesheet concepts to the automatic creation of Vendor Bills. Thus, we needed to capture our custom segment information captured on timesheets over to vendor bill lines.
Consequently, we need to enhance our SuiteScript 1.0 automatic vendor bill generation logic to include our custom segment information. We were wrong to naturally think it would be simple to reference the new segment information like all other database columns.
How to Reference NetSuite Custom Segments on Time Records
We needed to enhance an existing SuiteScript 1.0 script that looks up data on the timebill (timesheet) records. After some back and forth, we had to reach out to NetSuite Support for assistance. Here we learned we needed to add a ‘line.’ prefix to our code references. See below:
//SuiteScript 1.0 Custom Segment [must add line.] var srptype = columns[9] = new nlobjSearchColumn('line.cseg_pri_srp_rel'); var srpnature = columns[10] = new nlobjSearchColumn('line.cseg_pri_srp_nature');
Once we had the data, we could work with it on the vendor bill as we expected. The code below puts the value into the vendor bill line reference.
//SuiteScript 1.0 Custom Segment ap.setCurrentLineItemValue('item', 'cseg_pri_srp_rel', rec[i].getValue(srptype)); ap.setCurrentLineItemValue('item', 'cseg_pri_srp_nature', rec[i].getValue(srpnature));
Possible Explanation for Line Referencing
It’s not at obvious why we would need to reference timesheet entries (timebill) in this manner. However, we were given an explanation that timebill records are part of a “Time Sublist” because they are referenced in the “Transaction Column” options of the Custom Record definition.
Accordingly, these Custom Segment Transaction Column references require a ‘line.’ prefix when referencing the data. We were given the following SuiteAnswers article to help inform the explanation:
SuiteAnswer’s Article: Custom Segment Mapping from Source Transaction (Line Field) to Asset Proposal, Asset Record and Depreciation Journal (Line Field) | ID: 85255
Always be Learning with NetSuite
In our firm, we often find challenges like this custom segment reference puzzle. In our internal conversations, we often remind each other to stay humble and always be learning when it comes to the NetSuite platform.
If you found this article relevant, feel free to sign up for notifications to new articles as I post them. If you would like to be part of a high-caliber NetSuite team serving companies that value leadership and proven competence, let’s have a conversation.