GET SMARTER: (650) 579-0210

Workaround to update custom segments at line level

SmartClient doesn't support Custom Segments yet . However, the following is a workaround to update your custom segments at a line level using SmartClient.

Note: This approach works with fields at a line level. For updating Custom Segments at the header level only you may opt for a Workflow approach.

At a high level, this approach takes advantage of the fact that SmartClient supports Custom fields. Once the custom field has a value and the record is saved a SuiteScript is invoked to set the value of the actual Custom Segment field based on the value in the Custom field.

Fist you need to create a custom Transaction field of type List/Record that sources from the actual Custom Segment field. Associate this field to the record types desired (ie Journal Entry, etc.).

Note: The following is an indicative script for reference only to help get you started.


function copySegmentValue() {

var CUSTOM_FIELD_ID = 'custcol_physical_location',
CUSTOM_SEGMENT_ID = 'custcol_cseg_location',
SUBLIST = 'line';

var sourceField, destField, segValue;

var context = nlapiGetContext();
var exeContext = context.getExecutionContext();

var lineCount = nlapiGetLineItemCount(SUBLIST);
for (var i = lineCount; i > 0; i--) {

if (exeContext === 'webservices') {
sourceField = CUSTOM_FIELD_ID;
} else {
sourceField = CUSTOM_SEGMENT_ID;
destField = CUSTOM_FIELD_ID;

segValue = nlapiGetLineItemValue(SUBLIST, sourceField, i);
if (segValue) {
nlapiSelectLineItem(SUBLIST, i);
nlapiSetCurrentLineItemValue(SUBLIST, destField, segValue);
nlapiLogExecution('DEBUG', lineCount + ' lines were processed');


Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


Powered by Zendesk