Friday 4 January 2013

CSV Import in Netsuite

Lets see how this CSV thing works in Netsuite.

This is a sample code to load a CSV file (already present in your file cabinet) and submit it.CSV works only in restlet, schedule script and bundle installation.


var csvMap = '6'; //saved CSV import id(read below to set this)
var csvFile = nlapiLoadFile("948"); //csv file id from file cabinet                
var csvImport = nlapiCreateCSVImport();//creating a new csv import
csvImport.setMapping(csvMap);//setting import map
csvImport.setPrimaryFile(csvFile.getValue());//file to be imported
csvImport.setOption("jobName", "job1");//setting job status' job name       
var csvSubmitId = nlapiSubmitCSVImport(csvImport);//submitting the CSV



You can use this code , but first you need to set the CSV map.To do this,see below

Setup >>> Import/Export >>> Import CSV Record

Import Assistant page opens up.

Step 1 :
select the record type from the import type list (customer, employee,etc.)
Click on select button , browse and upload your csv file for mapping.

Step 2: look carefully and select the options of your choice.

Step 3:

Step 4: The main step

Select a field from field mapping window and map it to a netsuite field(remember to edit the mapping)

Step 5: done


No comments:

Post a Comment