'Automatic CSV Import Bank Data

Is it possible via scripting to import CSV data into "Match Bank Data".

Scenario. With some Australian banks not supported by Saltedge, and SFTP not a cost effective method for SMB, I have created a suitelet to convert the default National Australia Bank's CSV to the template for NetSuite Bank CSV.

I'd like to know if anyone knows if it is possible to take this converted CSV file and trigger the import via SuiteScript rather than the user manually importing via the Upload File screen (https://xxxxxxxxx.app.netsuite.com//erp/bankimport/ui/bankimport.nl)

enter image description here



Solution 1:[1]

Firts create the "Saved CSV Import" and you will get a ID, then in your Restlet or Suitelet send your National Australia Bank's CSV in BASE64 string and upload it in your file cabinet:

var fileObjCSV = file.create({
              name:  context.csvName+'.csv', 
              fileType: file.Type.CSV,
              contents: context.csv,
              description: 'CSV BANK',
              encoding: file.Encoding.UTF8,
              folder: 18084,//your folder ID
              isOnline: true
              });
              var fileIdcsv = fileObjCSV.save();

Now you have the file id (stored in your file cabinet ) and your saved import Id

 var scriptTask = task.create({taskType: task.TaskType.CSV_IMPORT});
      scriptTask.mappingId = 260; // saved importe ID
      var f = file.load({id: fileIdcsv});
     
      scriptTask.importFile = f;
      
      var csvImportTaskId = scriptTask.submit();

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 wozzarvl