I am trying to sync purchase order and sales order...
# suitescript
k
I am trying to sync purchase order and sales order sublists by itemId rather than by line number, since they wont always match. What is the best way to select a line in a sublist by
itemid
rather than by the
index
of the line Number?
Copy code
for (var i = 0; i < items.length; i++) {
            log.debug({
              title: "Expected Ship Date: ",
              details: items[i].expectedreceiptdate,
            });
            salesOrder.selectLine({
              sublistId: "item",
              line: i,
            });
            salesOrder.setCurrentSublistValue({
              sublistId: "item",
              fieldId: "expectedshipdate",
              value: items[i].expectedreceiptdate,
            });
            salesOrder.commitLine({
              sublistId: "item",
            });
          }
s
use this method
Copy code
findSublistLineWithValue
b
read the docs on the method to make sure you can live with its limitations
matching by item is not a general solution
k
I think that should work, thanks. Just trying to match the
Vendor item No.
shown here between PO and SOs: