Chris White
10/09/2019, 8:51 PMitem
sublist of an item receipt in a UE with an appropriate handler in a script included via clientScriptModulePath
. This button is intended to automatically create an inventorydetail
subrecord for each sublist line based on the provided quantity and a known bin ID. The record is in dynamic mode (I checked), but the getCurrentSublistSubrecord
is returning null
and I don't get why that is, seeing as I'm following the help for just this situation. The relevant code is as follows: // currentRecord is N/currentRecord
var rec = currentRecord.get();
var binId = getHKBinId(),
itemCount = rec.getLineCount('item');
for (var i = 0; i < itemCount; ++i) {
// Select this sublist line
rec.selectLine({
sublistId : 'item',
line : i
});
// Get the quantity to be received
var quantity = rec.getCurrentSublistValue({
sublistId : 'item',
fieldId : 'quantity'
});
// If we already have an inventorydetail
// subrecord, nothing to do
if ( rec.hasCurrentSublistSubrecord({
sublistId : 'item',
fieldId : 'inventorydetail'
}) ) {
log.debug('Has subrecord');
return;
}
// Create a new inventorydetail subrecord
var invDetail = rec.getCurrentSublistSubrecord({
sublistId : 'item',
fieldId : 'inventorydetail'
});
if ( !invDetail ) {
log.error({
title : 'getCurrentSublistSubrecord',
message : 'Unable to create a new inventorydetail subrecord'
});
return;
}
invDetail.selectNewLine({
sublistId : 'inventoryassignment',
});
invDetail.setCurrentSublistValue({
sublistId : 'inventoryassignment',
fieldId : 'quantity',
value : quantity
});
invDetail.setCurrentSublistValue({
sublistId : 'inventoryassignment',
fieldId : 'binnumber',
value : binId
});
invDetail.commitLine({
sublistId : 'inventoryassignment'
});
}
Thanks!battk
10/09/2019, 9:04 PMChris White
10/09/2019, 9:18 PM