I already tried Array.findIndex but it doesn't wor...
# suitescript
k
I already tried Array.findIndex but it doesn't work in SuiteScript 2.x 😕
s
lodash. though often finding an index isn't the best solution to a problem - it often suggests working at to low level.
k
Yeah I'm trying to update a 1.0 script that was all hard coded item mappings
I found a more elegant solution though
Copy code
const mapIndex = itemMapResult.map(obj => obj.itemId).indexOf(item);

      log.debug("Mapped Item", JSON.stringify(itemMap[mapIndex]));
typoed a little there but I think you get the idea
I'm refactoring it as I go along because it's ridiculously complex the way the original author hard coded everything
As I make sense of each section I simplify it
e
FWIW I'd recommend against using
2.x
for your scripts, particularly if you are writing any 2.1 and especially in this current case where
2.x
can mean two completely different versions of SuiteScript in different accounts depending on the preference setting.