How to find sublist line with 2 or more matching values? (using findSublistLineWithValue)

I was using findSublistLineWithValue but it finds the first line with the matching value.

What if I have more than 1 line with that value… how do I iterate through them?

Rookie Asked on September 19, 2019 in SuiteScript.
Add Comment
2 Answer(s)
Best answer

findSublistLineWithValue() only gives you the index of the first occurrence, or -1 if it does not exist.

To find indexes of multiple occurrences you would have to implement your own function. My recommendation would be serializing your sublist values into desired object array and then using standard JavaScript Array.filter() functionality from there.

Beginner Answered on September 19, 2019.
Add Comment

Serialize the sublist then just use Array.findIndex. Make sure to polyfill it first

Beginner Answered on October 10, 2019.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.