Single CSV file for different Records Import

Scenario

Feasibility of using a single CSV file for importing various types of records into NetSuite using task module in scheduled script

Created a scheduled script.

Created 2 Saved imports, one for customers and the other for items.

Saved a CSV file in suitescript folder under the name testcsvimport.csv

The sample is given below

Script used to import

function executeschedule(context) {
            try {
                log.debug("Script triggered", "Script triggered")
                let scriptTask1 = task.create({ taskType: task.TaskType.CSV_IMPORT });
                scriptTask1.mappingId = 'custimport_1_t2782962_140'
                let f = file.load('SuiteScripts/testcsvimport.csv');
                scriptTask1.importFile = f;
                let id1 = scriptTask1.submit();
                log.debug("id1", id1);
                let scriptTask2 = task.create({ taskType: task.TaskType.CSV_IMPORT });
                scriptTask2.mappingId = 'custimport_jj_test_csv_import';
                scriptTask2.importFile = f;
                let id2 = scriptTask2.submit();
                log.debug("id2", id2);
            } catch (error) {
                log.error("Error @executeschedule", error);
            }
        }

Leave a comment

Your email address will not be published. Required fields are marked *