Hi – has anyone encountered this error while tryin...
# suitescript
s
Hi – has anyone encountered this error while trying to remove line items from a Sales Order?
e
how are you removing those line items? I have never come across this on an SO (only similar on JE, for balancing the transaction)
s
Copy code
rec.removeLine({sublistId: 'item', line: committedSo.properties[i].lineid, ignoreRecalc: true});
Same.. I thought this balance error is only thrown by JEs
b
should probably allow script recalculation
s
Thanks - I'll try that
e
makes sense! let us know
s
will do
I can't seem to find any documentation on how to allow script recalculation
Can you point me in the right direction?
b
s
ah I'm such an idiot
thanks
Copy code
for (var i = linesToRemove.length;  i >= 0;  i--) {
    rec.removeLine({sublistId: 'item', line: linesToRemove[i], ignoreRecalc: false});
Setting ignorerecalc to false fixed the balance error but now what in gods name is this lol?
I'm not even inserting a line
b
you are iterating through
linesToRemove
wrong if it is an array
and you are removing lines dangerously if linesToRemove is not a sorted array
s
it is a sorted array
b
then the first statement still stands
there is no element at the length's index
s
Thank you – I just tested rec.removeLine({sublistId: 'item', line: 4, ignoreRecalc: false});
and it worked
What would you say is the best way to do this?
b
lookup how to iterate thorugh an array backwards in javascript
s
Thank you
b
although honestly if you reversed your sort, you can iterate though the array normally
s
I will try that as well but now I really want to learn iterating backwards through an array. Thanks a ton
worked! Thanks
127 Views