Craig
03/30/2021, 5:37 AMbattk
03/30/2021, 5:53 AMDefault Items to Zero Received/Fulfilled
is set to falseCraig
03/30/2021, 5:53 AMbattk
03/30/2021, 5:54 AMCraig
03/30/2021, 5:55 AMCraig
03/30/2021, 5:57 AMbattk
03/30/2021, 5:58 AMbattk
03/30/2021, 5:59 AMbattk
03/30/2021, 5:59 AMCraig
03/30/2021, 6:00 AMCraig
03/30/2021, 6:00 AMCraig
03/30/2021, 6:02 AMCraig
03/30/2021, 6:02 AMbattk
03/30/2021, 6:02 AMCraig
03/30/2021, 6:02 AMCraig
03/30/2021, 6:03 AMCraig
03/30/2021, 6:06 AMbattk
03/30/2021, 6:16 AMbattk
03/30/2021, 6:16 AMbattk
03/30/2021, 6:16 AMrequire(["N/record"], function (record) {
var fulfillmentRecord = record.transform({
fromType: "salesorder",
fromId: "29411",
toType: "itemfulfillment",
});
log.debug(
"line 0 itemreceive: " +
fulfillmentRecord.getSublistValue({
sublistId: "item",
fieldId: "itemreceive",
line: 0,
})
);
log.debug(
"line 1 itemreceive: " +
fulfillmentRecord.getSublistValue({
sublistId: "item",
fieldId: "itemreceive",
line: 1,
})
);
log.debug(
"line 0 quantity: " +
fulfillmentRecord.getSublistValue({
sublistId: "item",
fieldId: "quantity",
line: 0,
})
);
log.debug(
"line 1 quantity: " +
fulfillmentRecord.getSublistValue({
sublistId: "item",
fieldId: "quantity",
line: 1,
})
);
var PLFulfilledItems = [{ quantity: 5 }, { quantity: 5 }];
for (var i = 0; i < PLFulfilledItems.length; i++) {
var index = fulfillmentRecord.findSublistLineWithValue({
sublistId: "item",
fieldId: "item",
value: {},
});
log.debug("index: " + index);
fulfillmentRecord.setSublistValue({
sublistId: "item",
fieldId: "itemreceive",
line: index,
value: true,
});
fulfillmentRecord.setSublistValue({
sublistId: "item",
fieldId: "quantity",
line: index,
value: PLFulfilledItems[i].quantity,
});
}
fulfillmentRecord.save();
});
battk
03/30/2021, 6:17 AMCraig
03/30/2021, 6:18 AMbattk
03/30/2021, 6:22 AMCraig
03/30/2021, 6:22 AMbattk
03/30/2021, 6:22 AMCraig
03/30/2021, 6:23 AMstalbert
03/30/2021, 11:44 AM_.find()
is what I'd use - you either get a line object or not - far closer to the intent of the code imho.alien4u
03/30/2021, 3:21 PMfindSublistLineWithValue
is documented and clearly states that it returns -1, so why not checking index
!== or === -1?alien4u
03/30/2021, 3:24 PMfindSublistLineWithValue
with the exception of multiple/duplicate possible values in the sublist in which case I write my own implementation, but I don't see how this is a bug in any shape way or form.stalbert
03/30/2021, 4:49 PMalien4u
03/30/2021, 6:34 PMindexOf
so I guess I still don't get how checking -1 is weird or inconvenient.stalbert
03/30/2021, 8:20 PMindexOf
you have to obey its rulesCraig
03/31/2021, 6:34 AM