I want my client script to automate the setting of...
# suitescript
w
I want my client script to automate the setting of inventory detail quantity on an item receipt. Thankfully all my items have a default bin and the global setting to use the default bins is on. However when changing the quantity I get a "Not supported on current subrecord: CurrentSubrecord.setCurrentSublistValue.". This happens in both create and edit client contexts Here is a sample code
require(['N/currentRecord'], function(currentRecord) {
const record = currentRecord.get();
record.selectLine({
sublistId: 'item',
line: 0
});
const quantityToSet = record.getCurrentSublistValue({
sublistId: 'item',
fieldId: 'quantity'
})
const inventoryDetailSubrecord = record.getCurrentSublistSubrecord({
sublistId: 'item',
fieldId: 'inventorydetail'
});
inventoryDetailSubrecord.selectLine({
sublistId: 'inventoryassignment',
line: 0
});
// this line throws the error "Not supported on current subrecord: CurrentSubrecord.setCurrentSublistValue."
inventoryDetailSubrecord.setCurrentSublistValue({
sublistId: 'inventoryassignment',
fieldId: 'quantity',
value: quantityToSet
});
// Commit the line
inventoryDetailSubrecord.commitLine({
sublistId: 'inventoryassignment'
});
});