Tuesday, April 16, 2019

Script >How to retrieve values from a multi-select field via scripting

If you have an multi-select custom field on a sales order and you would like to know how to retrieve the values that are on an existing record you can use the following code:
*Note: Multi-Select custom fields returns an array of values, you need to iterate through the array to retrieve the actual values*

// 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);

No comments:

Post a Comment