using standardLines.getLine on a for loop only giv...
# ask-stanley-ai
a
using standardLines.getLine on a for loop only gives me the zero indexed line while trying to access it by static line number gives the specifc data for that line
c
AI generated answer (using internal Slack threads):
It seems like you're experiencing an issue with the
standardLines.getLine
method in a for loop, where it only returns the zero indexed line. However, when you try to access it by a static line number, it gives the specific data for that line. This behavior could be due to the way the
selectLine
method works in SuiteScript. When you use
selectLine
in a loop, it doesn't automatically advance to the next line after a
commitLine
operation. Instead, it stays on the current line until you explicitly tell it to move to the next line. This is why you're always getting the zero indexed line in your loop. When you use a hardcoded line number,
selectLine
is able to select that specific line because you're explicitly telling it which line to select. Here's a potential solution: After each
commitLine
operation, you could use the
selectNewLine
method to move to the next line. Here's an example:
Copy code
javascript
for (var i = 0; i < totalItemsCount; i++) {
    currentRecord.selectLine({ sublistId: 'item', line: i });
    // Perform your operations here...
    currentRecord.commitLine({ sublistId: 'item' });
    if (i < totalItemsCount - 1) {
        currentRecord.selectNewLine({ sublistId: 'item' });
    }
}
This code will select each line in the sublist, perform the necessary operations, commit the line, and then move to the next line (if there is one). ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.809128284
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.807015657
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.805000782
Please provide your feedback on this answer.
a
custom gl suitescript 2.x standardLines loop
c
Thank you for your feedback