Import a manufacturing component CSV file into NetSuite using task.CsvImportTask inside a scheduled script, linking a secondary file for multi-file imports
Create or locate the saved CSV import mapping in Setup > Import/Export; note its numeric internal ID (mappingId).
In a SuiteScript 2.x scheduled script, require N/task and N/file; load the primary CSV from the file cabinet using file.load({id: primaryFileId}).
If the import uses linked files (e.g., sublist data in a separate CSV), load each linked file and pass them as a key-value object: {linkedFiles: {'Secondary File': linkedFileObj}}.
Create the task: var csvTask = task.create({taskType: task.TaskType.CSV_IMPORT, mappingId: MAPPING_ID, importFile: primaryFile, linkedFiles: linkedFilesObj}); var taskId = csvTask.submit();
Poll status by calling task.checkStatus({taskId: taskId}) in a subsequent scheduled run; status values include PENDING, PROCESSING, COMPLETE, and FAILED.
Log errors from the returned MappingTaskStatus object; retrieve the error file via the job's output file cabinet location for row-level diagnostics.
Known gotchas
task.CsvImportTask.submit() is only permitted in scheduled scripts, RESTlets, and bundle installation scripts — calling it from a map-reduce getInputData or a Suitelet will throw an unsupported context error.
The mappingId must reference an existing, active saved import mapping; if the mapping was modified after the script was written, column alignment may silently shift causing wrong-field imports.
Large CSVs are processed asynchronously; the taskId returned by submit() is not the final job ID visible in the Import Job Status UI — use task.checkStatus to correlate.
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp