SSS_INVALID_SUBLIST_OPERATION CurrentRecord.select...
# ask-stanley-ai
n
SSS_INVALID_SUBLIST_OPERATION CurrentRecord.selectLine; ID: var currLineIndex = currRec.getCurrentSublistIndex({ sublistId: 'item' }); currRec.selectLine({ sublistId: 'item', line: Number(currLineIndex) + 1 , ignoreRecalc: true}); currRec.setCurrentSublistValue({ sublistId: 'item', fieldId: 'item', value: itemId }); currRec.setCurrentSublistValue({ sublistId: 'item', fieldId: 'quantity', value: calcPromo }); currRec.setCurrentSublistValue({ sublistId: 'item', fieldId: 'amount', value: 0 }); currRec.setCurrentSublistValue({ sublistId: 'item', fieldId: 'taxcode', value: 11 }); currRec.commitLine({ sublistId: 'item' });
c
AI generated answer (using internal Slack threads):
The error
SSS_INVALID_SUBLIST_OPERATION
typically occurs when you're trying to perform an operation on a sublist line that doesn't exist or is not currently selected. In your case, you're trying to select a line that may not exist. The
selectLine
method selects a line in a sublist. The line number is zero-based, so the first line is line 0, the second line is line 1, and so on. If you try to select a line that doesn't exist (for example, if there are only 3 lines and you try to select line 4), you'll get the
SSS_INVALID_SUBLIST_OPERATION
error. In your code, you're trying to select the line at
currLineIndex + 1
. If
currLineIndex
is the index of the last line in the sublist, then
currLineIndex + 1
doesn't exist, which is why you're getting the error. Here's a corrected version of your code:
Copy code
javascript
var currLineIndex = currRec.getCurrentSublistIndex({
    sublistId: 'item'
});

if (currLineIndex < currRec.getLineCount({sublistId: 'item'}) - 1) {
    currRec.selectLine({ sublistId: 'item', line: Number(currLineIndex) + 1 , ignoreRecalc: true});

    currRec.setCurrentSublistValue({ sublistId: 'item', fieldId: 'item', value: itemId });
    currRec.setCurrentSublistValue({ sublistId: 'item', fieldId: 'quantity', value: calcPromo });
    currRec.setCurrentSublistValue({ sublistId: 'item', fieldId: 'amount', value: 0 });
    currRec.setCurrentSublistValue({ sublistId: 'item', fieldId: 'taxcode', value: 11 });

    currRec.commitLine({ sublistId: 'item' });
}
This code first checks if
currLineIndex + 1
is a valid line number before trying to select it. ****** 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.890420914
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.875146091
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.868957639
Please provide your feedback on this answer.