Import Customer Deposit CSV via Script (old version)

CSV Import of Customer Deposit can be accomplished by uploading the CSV file in the File Cabinet and using nlapiLoadFile to read and save it line by line. 

// load csv file from file cabinet

var arrLines = nlapiLoadFile(1913).getValue().split(/n|nr/);

// loop to get all lines

for (var i = 1; i < arrLines.length – 1; i++) {

var content = arrLines[i].split(‘,’);

// add the columns of the CSV file here

var customer = content[0]; //first column

var payment = content[1]; //second column

// create customer deposit using fields from csv

var custDepo = nlapiCreateRecord(‘customerdeposit’, {recordmode:’dynamic’});

custDepo.setFieldValue(‘customer’,customer);

custDepo.setFieldValue(‘payment’, payment);

// submit record

nlapiSubmitRecord(custDepo);

}

Leave a comment

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