Wednesday, February 20, 2019

Ability to Retrieve Item Options Value on Sales Order using SuiteScript

Using getLineItemValue method users are able to retrieve the values in the option column fields.

Sample scenario:


var optionString = rec.getLineItemValue('item','options',1);

optionString will return the value below:

First step, separate the set of options on the option column field using CHR(4) or the ANSI control character with code 4. 

var cString = String.fromCharCode(4);               
var set_of_option_array = optionString.split(cString);
     

set_of_option_array variable will contain two values

set_of_option_array[0]:  

set_of_option_array[1]: 

On the next step, split the option values using CHR(3) or the ANSI     control character with code 3.

var ext_String = String.fromCharCode(3);               
var each_option = set_of_option_array[i].split(etxString);               
*each_option is an array of string that contains the values of option               

set_of_option_array[0]:               
each_option[0] CUSTCOL4       
each_option[1] F       
each_option[2] Flavor Cookie       
each_option[3] 2       
each_option[4] Ola Oatmeal       
   
set_of_option_array[1]:           
each_option[0] CUSTCOL5   
each_option[1] F   
each_option[2] Size   
each_option[3] 3   
each_option[4] Small

Below is a Suitelet sample code in retrieving the option values:

No comments:

Post a Comment