Hi all, we have found a defect with the N/search m...
# suitescript
h
Hi all, we have found a defect with the N/search module and lookupFields function on multiselect fields, it maps the text incorrectly to the values in the returned object. Defect 656764 - SuiteScript 2.0 > N/search > search.lookupFields() > Custom Multi-Select Field > Incorrect Text/Value Mapping This is U6 priority currently; if you use/rely on this function please raise a case to get NetSuite to fix it with greater urgency!
n
"it maps the text incorrectly to the values in the returned object" - meaning the text / internal values are not aligned?
h
That is right, we have seen that is inconsistent too. When you have 3 entries in a multiselect it seems the most consistent way to generate the defect. These are the alternate solutions they sent. 1. Put an extra character in the text so the value will be sorted alphabetically. a. (e.g., AStart of Line, BMiddle of Line, CEnd of Line) 2. Use the IDs that are being returned then use a search to get the correct names to associate with those IDs. The pseudocode is below: a. Use search.lookupFields to get the selected options from the multi-select field. b. Iterate over the returned array. For each object in the Array, get the value and push it into a new array (call it idArray). c. Run a search for all instances of the custom record that is used as the list for the multi-select field. d. For each result, if its internal id is in the idArray, create an object with the name and internal id of the record.
n
That sounds like you you just need to be sure the id / text value match which you can do simply by getting the select options of the field, unless I've misunderstood?