Retrieve Values from a Multi-Select Field via Scripting

Written by
Manuelito Macalinao
Published on
November 30, 2023 at 7:37:22 AM PST November 30, 2023 at 7:37:22 AM PSTth, November 30, 2023 at 7:37:22 AM PST

Scenario

If multi-select custom field exists on a sales order, the values should be retrieved that are present on an existing record.

Note:Multi-Select custom fields returns an array of values, hence it is needed to iterate through the array to retrieve the actual values

Solution

// 523 is the internal id of an existing sales order.var record =nlapiLoadRecord('salesorder',523);var custField= record.getFieldTexts('custbody4');var val;for(var i =0; i < custField.length; i++){ val = custField[i];nlapiLogExecution('DEBUG','Custom Field Value Selected'+ val, val);}