load record error: UNEXPECTED_ERROR
In suitelet, working for loading record for updating some record field. Have not reached set value to field and save() but got UNEXPECTED_ERROR when loading records. Tried these on INVOICE and CREDIT MEMO types and both give the same error message.
In the same script, load saved search without any issue. Searched google about this but no much information available. Netsuite experts please recommend what to do to resolve this issue. I have code below to repeat this issue in Netsuite debugger. The simplified code related to this issue is below:
require([‘N/record’], function (record) {
var exports = {};
var tranids = [‘CRM3899′,’INV0401’];
var requestId = ‘123456’;
updateRecordExportStatus(tranids, requestId);
function updateRecordExportStatus(tranids, requestId) {
log.debug(‘updateRecordExportStatus’, ‘TRANIDs: ‘ + tranids + ‘, requestId: ‘ + requestId);
var recordType;
for (var i = 0; i < tranids.length; i++) {
var recordType;
if (tranids[i].indexOf(‘INV’) >= 0) {
recordType = record.Type.INVOICE;
} else if (tranids[i].indexOf(‘CRM’) >= 0) {
recordType = record.Type.CREDIT_MEMO
}
log.debug(‘updateRecordExportStatus’, ‘Record Type is: ‘ + recordType)
try {
var loadedRecord = record.load({type: recordType, id: tranids[i], isDynamic: false});
loadedRecord.setValue( {fieldId:’custbody5’, value: ‘T’ });
loadedRecord.setValue( {fieldId:’custbody_ofc_request_id’, value: requestId });
loadedRecord.save();
log.debug(‘updateRecordExportStatus’, ‘Save Record passed’);
} catch(ex)
{
log.error(‘updateRecordExportStatus’, ‘load or write record exception’ + ex.message);
throw ex;
}}}
exports.onRequest = onRequest;
return exports;
});
Error from debugger is below:
| UNEXPECTED_ERROR | ||
| {“type”:”error.SuiteScriptError”,”name”:”UNEXPECTED_ERROR”,”message”:null,”stack”:[“<anonymous>(N/record/recordImpl.js)”,”updateRecordExportStatus(adhoc$-1$debugger.user:21)”,”<anonymous>(adhoc$-1$debugger.user:6)”,”<anonymous>(adhoc$-1$debugger.user:1)”],”cause”:{“type”:”internal error”,”code”:”UNEXPECTED_ERROR”,”details”:null,”userEvent”:null,”stackTrace”:[“<anonymous>(N/record/recordImpl.js)”,”updateRecordExportStatus(adhoc$-1$debugger.user:21)”,”<anonymous>(adhoc$-1$debugger.user:6)”,”<anonymous>(adhoc$-1$debugger.user:1)”],”notifyOff”:false},”id”:”1fa404e8-2a46-4432-ad02-1c9eab4d3ab7-2d323032322e31312e3139″,”notifyOff”:false,”userFacing”:false} | ||
Hi,
When calling record.load(), you need the Internal ID, not the Transaction ID.
Thanks,
Chris



