Personally I'd probably have something like this i...
# suitescript
e
Personally I'd probably have something like this in a highly accessible place:
Copy code
const sublistFields = [
  {
    id: "custpage_blah1",
    type: serverWidget.Type.WHATEVER,
    label: "Blah"
  },
  ...
];

const sublistIds = sublistFields.map((f) => { return f.id; });

...

sublistFields.forEach((f) => { sublist.addField(f); });

...

for (i : 0 => lineCount) {
  var rowValues = sublistIds.map((id) => { return request.getSublistValue({sublistId: "blah", fieldId: id, line: i});
  ...
}
```
s
fwiw, the curly braces in your lambdas are optional. so are the semicolons 🙂
e
I know there's a lot more you can do with the lambdas
but I don't know that syntax very well off the top yet 😞
some day I will learn all the ES6+ things...
s
I got spoiled programming in Scala for a while, so was pretty jazzed to know some similiarities exist in modern JS. If your lambda is a single line that returns something, you can omit the curly braces as the
return
keyword. So a lambda like
() => 5
is equivalent to
() => { return 5 }
. IMHO that reads more cleanly and it's more 'functional' in the sense that it is treating
()=> 5
alike an expression that gets evaluated for to a value (5). I like this as it's akin to Scala which is an 'expression oriented' language https://en.wikipedia.org/wiki/Expression-oriented_programming_language