I am trying to uncheck "Closed" on 2 out of 4 lin...
# suitescript
n
I am trying to uncheck "Closed" on 2 out of 4 lines of a SO. When i log, it is hitting two lines like it should and saving the SO, but for some reason instead of 2 lines being closed and 2 not closed, it makes all 4 lines Not Closed.
Copy code
var salesOrderRecDelete = record.load({
                            type: 'salesorder',
                            id: soIDDelete,
                            isDynamic: true
                        });

                        for (var n = 0; n < salesOrderRecDelete.getLineCount({ sublistId: 'item' }); n++) {
                            salesOrderRecDelete.selectLine({
                                sublistId: 'item',
                                line: n
                            });

                            // var woline = salesOrderRec.getSublistValue({
                            //     sublistId: 'item',
                            //     fieldId: 'custcol_dc_wo_line',
                            //     line: n
                            // });

                            var wolinedelete = salesOrderRecDelete.getCurrentSublistValue({
                                sublistId: 'item',
                                fieldId: 'custcol_dc_wo_line'
                            });

                            if (wolinedelete) {
                                if (getWOLineSegment(wolinedelete) === invoiceSegmentDelete) {
                                    // salesOrderRec.setSublistValue({
                                    //     sublistId: 'item',
                                    //     fieldId: 'isclosed',
                                    //     line: n,
                                    //     value: false
                                    // });
                                    salesOrderRecDelete.setCurrentSublistValue({
                                        sublistId: 'item',
                                        fieldId: 'isclosed',
                                        value: false,
                                        ignoreFieldChange: true
                                    });
                                }
                            }

                            salesOrderRecDelete.commitLine({
                                sublistId: 'item'
                            });
                        }
                        var deleteSORECSAVE = salesOrderRec.save();
b
you havent shared enough for someone to reproduce the issue
Copy code
if (getWOLineSegment(wolinedelete) === invoiceSegmentDelete) {
is unknown to us
getWOLineSegment, wolinedelete and invoiceSegmentDelete are unknown to us
n
@battk sorry, gonna delete this. Turns out there was another script deeply hidden that was counter acting what i was doing.