I have create a simple ClientScript to update a sales order sublist value from item fulfillment.
when the script run the record.save() API, I got error JS_EXCEPTION - TypeError: Cannot read property 'name' of undefined.
Here Is my Script :
/**
*@NApiVersion 2.x
*@NScriptType ClientScript
*/
define(['N/record', 'N/currentRecord', 'N/search', 'N/log'], function (record, currentRecord, search, log) {
function saveRecord(context) {
var currentRecord = context.currentRecord;
var soId = currentRecord.getValue({
fieldId: 'createdfrom'
});
var soRecord = record.load({
type: record.Type.SALES_ORDER,
id: soId,
isDynamic: true
});
var soItemCount = soRecord.getLineCount({
sublistId: 'item'
});
log.debug({
title: "soItemCount",
details: soItemCount
});
for (var so = 0; so < soItemCount; so++) {
soRecord.selectLine({
sublistId: 'item',
line: so
});
soRecord.setCurrentSublistValue({
sublistId: 'item',
fieldId: 'custcol_need_approval',
value: true
});
soRecord.setCurrentSublistValue({
sublistId: 'item',
fieldId: 'custcol_fulfill_qty',
value: 90
});
}
soRecord.commitLine({
sublistId: 'item'
});
soRecord.save();
return true;
}
return {
saveRecord: saveRecord
};
});
can anyone give me a suggestion with my script ?