Hi everyone! Hope you all are doing well. I am try...
# suitescript
h
Hi everyone! Hope you all are doing well. I am trying to set Inventory Details on Inventory Adjustment record but even after following the whole flow as first setting item then location then Adjust inventory by when I try to add Inventory details subrecord I get an error TypeError Cannot read property 'selectNewLine' of null can anyone please help me as to what I am doing wrong?
b
Share the code
Keep in mind this will simply not work in client script for the current record
h
This is where I am confused as it does not work in before load script as well
var currentRecord = context.currentRecord;
var currentSubrecord = currentRecord.getCurrentSublistSubrecord({
sublistId: 'inventory',
fieldId: 'inventorydetail'
});
currentSubrecord.selectNewLine({
sublistId: 'inventoryassignment'
});
currentSubrecord.setCurrentSublistValue({
sublistId: 'inventoryassignment',
fieldId: 'issueinventorynumber',
value: serialnumber,
ignoreFieldChange: false
});
currentSubrecord.setCurrentSublistValue({
sublistId: 'inventoryassignment',
fieldId: 'quantity',
value: parseInt(-Subrecordquantity),
ignoreFieldChange: false
});
currentSubrecord.commitLine({
sublistId: 'inventoryassignment'
});
b
i havent tried the before load user event script for setting line item fields
that doesnt really sound sane for line items on create, which is the only time you have a chance at getting that to work
c
The only way to edit sublist subrecords like Inventory Detail is in deferredDynamic / Standard mode. https://stackoverflow.com/questions/43526532/unable-to-set-inventory-detail-on-item-fulfillment-record-suitescript-2