/**
*@NApiVersion 2.1
*@NScriptType ScheduledScript
*/
define([ 'N/search', 'N/file', 'N/task'],
(search, file, task) => {
execute = (context) => {
log.debug('==START==','==START==');
try {
const allFiles = getFiles();
for(let fileId of allFiles) {
// create CSV import task
const scriptTask = task.create({taskType: task.TaskType.CSV_IMPORT});
// change this to your mapping ID
scriptTask.mappingId = 116;
const csvFile = file.load(fileId);
scriptTask.importFile = csvFile;
// submit csv import job
const csvImportTaskId = scriptTask.submit();
log.debug('CSV task submitted ID', csvImportTaskId);
}
}
catch(e) {
log.error('Error', JSON.stringify(e));
}
}
getFiles = () => {
const folderSearchObj = search.create({
type: "folder",
filters: [
// change this ID to the folder ID where the CSV files are
["internalidnumber","equalto", 655]
],
columns: [
search.createColumn({
name: "internalid",
join: "file",
label: "Internal ID"
})
]
});
let allFiles = [];
folderSearchObj.run().each(function (result) {
let internalid = result.getValue({
name: "internalid",
join: "file",
label: "Internal ID"
});
allFiles.push(internalid);
return true;
});
return allFiles;
}
return {execute};
});
Jaime Requena is a seasoned NetSuite Consultant and Solutions Architect, known for delivering WHITE GLOVE service to businesses. With 15+ years of experience and 3x certifications in ERP, Developer, and Admin, Jaime specializes in highly customized NetSuite accounts, transforming operations for 200+ satisfied customers all across the globe.
We aim to bring unmatched expertise and professionalism to your NetSuite initiatives. Let’s talk about how our NetSuite consultancy can make a difference!
It’s Been 4+ Years Now And We Have Worked With Hundreds Of Clients, Building Our Way To The Top, One Happy Client After Another! Their Voices Of Satisfaction Serve As A Testament To Our Success –