Marc
09/23/2024, 2:43 PMCeligo AI
09/23/2024, 2:43 PMAI generated answer (using internal Slack threads):Based on the conversations, it seems that you are trying to populate the Lot Number on the Inventory Detail Subrecord using a beforeSubmit script. However, you are facing issues because the Quantity is a mandatory field if you're trying to set a Lot Number on the subrecord. From the discussions, it appears that the Inventory Detail Subrecord gets created on submit, which should work, but is required for validation prior to record save and therefore beforeSubmit. One user mentioned that they were able to write to the 'inventoryassignment' sublist using
inventoryDetailSubrecord.setSublistValue()
even though the inventory detail subrecord hasn't been created yet and has an id of null.
Another user mentioned that they were able to solve a similar issue by deleting the existing subrecord and creating a new one. This might be a workaround for your issue as well.
Here is a code snippet from one of the conversations that might be helpful:
javascript
define(["N/record", "N/url", "N/log"], function(r, url, log) {
var exports = {};
function zeroQuantity(recordId) {
var record = r.load({
id : recordId,
type : r.Type.INVENTORY_NUMBER
});
try {
record.setSublistValue({
sublistId : 'locations',
fieldId : 'quantityonhand',
line : 0,
value : 0
});
record.save({
enableSourcing : true,
ignoreMandatoryField : true
});
}
catch (e) {
alert(e.message);
}
var redirect = url.resolveRecord({
recordType : 'inventorynumber',
recordId : recordId
});
window.location.href = redirect;
}
exports.pageInit = function() { return true; };
exports.zeroQuantity = zeroQuantity;
return exports;
});
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
09/23/2024, 2:44 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.877884746
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.869627416
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.866119087
Celigo AI
09/23/2024, 2:44 PM