I am getting error for the creation of Inventory t...
# suitescript
h
I am getting error for the creation of Inventory transfer record in Map reduce script. If I load and save existing record it works fine but when save the new record, script give this error "Items you have requested in the record have been deleted since you retrieved the form". Creation through UI is fine for same data. Thanks in advance for any input.
l
Usually, this error occur when you try to access a sublist line that doesn't exists
On 2.0, Sublists line starts at 0 so check if there is any looping on sublists if it isn't >= sublist count
h
@Luiz Morais I have checked with sub list line all ok even script is working fine for record.load and and record.copy I have tried in console with ss 1.0 still the same error for creation. Thanks
l
Do you mind paste your code here?
h
require(['N/record'],function(record){ var invTransRecord = record.create({ type: 'inventorytransfer', isDynamic: true, }); invTransRecord.setValue({fieldId : 'trandate', value: new Date()}); invTransRecord.setValue({fieldId : 'customform', value: 105}); //invTransRecord.setValue({fieldId : 'postingperiod', value: '123'}); invTransRecord.setValue({fieldId : 'location', value: '6'}); invTransRecord.setValue({fieldId : 'inventorylocation', value: 7}); invTransRecord.selectLine({ sublistId: 'inventory', line:0 }); invTransRecord.setCurrentSublistValue({ sublistId: 'inventory', fieldId: 'item', value: 5935}) invTransRecord.setCurrentSublistValue({ sublistId: 'inventory', fieldId: 'adjustqtyby', value: '1' }); invTransRecord.commitLine({ sublistId: 'inventory', }); console.log(invTransRecord); var invRecordId = invTransRecord.save({ enableSourcing: true, ignoreMandatoryFields: true }); console.log(invRecordId); });
l
Sorry late reply... You're creating a record so there isn't any lines... to create a new line you need call invTransRecord.insertLine