I have a script that extracts Expiration Date from Inventory Detail that is running successfully on a SandBox/Production account. I copied this script to another Sandbox account (Netsuite OneWorld) with the same settings. However, the execution logs show this error:
ReferenceError: "define" is not defined. (INVOCATION_WRAPPER#11)
In what situation keyword "define" is not recognized? Here is the script:
/**
* @NApiVersion 2.0
* @NScriptType ClientScript
*/
define(['N/record','N/search'], function(record,search) {
function saveRecord(context) {
var rec= context.currentRecord;
var customer = rec.getValue({fieldId : 'entity'});
setExpiryDate(rec);
log.debug(title+'setExpiryDate','completed');
return true
}
function setExpiryDate(rec){
var title = 'setExpiryDate()::';
try{
var nsTranRec = rec;
var lineCount = nsTranRec.getLineCount({sublistId: "item"});
for (var i = 0; i < lineCount; i++) {
lineInvDetailInfo = [];
nsTranRec.selectLine({sublistId: "item", line: i});
hasSublistRec = nsTranRec.hasCurrentSublistSubrecord({
sublistId: "item",
fieldId: "inventorydetail"
});
if (hasSublistRec) {
sublistRec = nsTranRec.getCurrentSublistSubrecord({
sublistId: "item",
fieldId: "inventorydetail"
});
var tempExpiry = [];
sublistRecLineCount = sublistRec.getLineCount({sublistId: "inventoryassignment"});
for (var s = 0; s < sublistRecLineCount; s++) {
lineExpiry = sublistRec.getSublistValue({
sublistId: "inventoryassignment",
fieldId: "expirationdate",
line: s
});
var dat = new Date(lineExpiry);
var tempdate ;
var month = dat.getMonth()+1;
var day = dat.getDate();
var year = dat.getFullYear();
tempdate = month+'/'+day+'/'+year;
log.debug(title+'tempdate',tempdate)
if(lineExpiry){
tempExpiry.push(tempdate)
}
}
if(tempExpiry.length){
nsTranRec.setCurrentSublistValue({
sublistId: "item",
fieldId: "custcol_hr_expirydate",
value: tempExpiry.join(', ')
});
}
nsTranRec.commitLine({sublistId: "item"});
}
}
}catch(error){
log.error(title+error.name,error.message)
}
}
return {
saveRecord: saveRecord
}
});
Even when I edit the script directly within Netsuite, the editor's autocomplete does not seem to recognize define.
The account I am working with have ton of 2.0 scripts already.
Thanks in advance.