I have client script that will populate PO line it...
# suitescript
d
I have client script that will populate PO line item on fieldChange. Before i populate the line items, i would like to removeLine first, it works on Edit record, but not on New Record
Copy code
var poLineCount = currentRec.getLineCount({
                    sublistId: 'item'
                });
                log.debug('poLineCount', poLineCount);
                for (var j = 0; j < poLineCount; j++) {
                    currentRec.selectLine({
                        sublistId: 'item',
                        line: 0
                    })
                    currentRec.removeLine({
                        sublistId: 'item',
                        line: 0
                    });
                }
SSS_INVALID_SUBLIST_OPERATION CurrentRecord.selectLine is my approach correct ? did i miss something thanks
e
You don't need to select the line first. Remove the lines in reverse.
for (let j = poLineCount - 1; j >= 0; j--) {removeLine...}
currentRec.removeLine({sublistId: 'item', line: j})
d
sorry i got type on the line, yes, it should be j instead of 0
let me try to remove in reverse
wow it works in reverse, thanks for your help @ehcanadian
👍 1
i wonder why it works in Edit mode though, without doing it in reverse