Tuesday, September 25, 2018

How to parse the value of a Multiple Select field?

Question: The user needs to parse the values of a Multiple Select field.
 
Answer:
 
Use String.fromCharCode(5) as the split condition.
 
Notes: 

1. When the user gets the values in a Multiple Select field uisng  nlapiGetFieldValue, it displays values like this: 215|217. The value retrieved is actually character5.
 
2. Use the code above to parse the values of a Multiple Select field correctly.
 
3. On the example below, treat the pipe operator as the separator seen when used with nlapiGetFieldValue on a Multiple Select field. The actual character is not rendered correctly in this editor.
 
Example:
 
var strSample = 'USER|XXX';
 
var arrResult = strSample.split(String.fromCharCode(5));
 

No comments:

Post a Comment