Home > Net >  ReferenceError: file is not defined - Suitescript
ReferenceError: file is not defined - Suitescript

Time:10-12

I resolved some earlier issues and got the below script to validate and deploy. However it fails and in the logs I see this error:

ReferenceError: file is not defined [at Object.execute (/SuiteScripts/purchasing.js:11:9)]

but my file is definitely there in that location and is defined in the script.

All help greatly appreciated.

/**
 * @NApiVersion 2.1
 * @NScriptType ScheduledScript
 */

define(['N/task'], 
function (task) {
function execute(scriptContext){
var scriptTask = task.create({taskType: task.TaskType.CSV_IMPORT});
scriptTask.mappingId = 212; 
var f = file.load('SuiteScripts/purchasing2.csv');
scriptTask.importFile = f;
var csvImportTaskId = scriptTask.submit();
};
return{
    execute: execute
    };
});

CodePudding user response:

You should load the N/file module as well.

define(['N/task', 'N/file'], function(task, file) {

  ....

})
  • Related