I am very new to Netsuite. I have the task of extracting the the Vendor in csv format to file cabinet. After searching on the internet I found a sample and tweaked it to what I want. However, after the export some fields like subsidiary is exporting with Internalid. I am not sure why. Please help me out with this.

function createFile(){

try{
var searchResults = nlapiSearchRecord('vendor', 'customsearch_davoil_apx_vendor');
var csvBody = '';

if (searchResults == null || searchResults.length < 1) return;

for (var i=0; i<searchResults.length; i++){
  
csvBody += searchResults[i].getValue('subsidiary') + ',';
csvBody += searchResults[i].getValue('entityid') + ',';
csvBody += searchResults[i].getValue('subsidiary') + ',';
csvBody += searchResults[i].getValue('companyname') + ',';
csvBody += searchResults[i].getValue('address1') + ',';
csvBody += searchResults[i].getValue('address2') + ',' ;
csvBody += searchResults[i].getValue('city') + ',';
csvBody += searchResults[i].getValue('state') + ',';
csvBody += searchResults[i].getValue('zipcode') + ',';
csvBody += searchResults[i].getValue('country') + ',';
csvBody += searchResults[i].getValue('terms') + ',';
" " + ',';
" " + ',';
csvBody += searchResults[i].getValue('phone') + ',';
" " + ',';
csvBody += searchResults[i].getValue({name:'contact', join:'contactprimary'}) + ',';
csvBody += searchResults[i].getValue('currency') + ',';
csvBody += searchResults[i].getValue('category') + ',';
csvBody += searchResults[i].getValue({name:'payablesaccount', join:'account'}) + ',';

csvBody += searchResults[i].getValue({name:'expenseaccount', join:'expaccount'}) + ',';

csvBody += searchResults[i].getValue('isinactive') + '\n';

if( searchResults[i] == searchResults.length){
    csvBody += EOD|vd_mstr|Rowcount|searchResults.length;
    EOF

}

}

var file = nlapiCreateFile('APXPress_Vendor_${filename}_051820_081300.csv', 'CSV', csvBody);
file.setFolder('766');
nlapiSubmitFile(file);
}catch(e){

nlapiLogExecution('Error', 'createFile', 'Error while creating file - ' + e.message);
}

}
1

There are 1 answers

2
erictgrubaugh On BEST ANSWER

All of the fields you mentioned are Select fields (i.e. dropdown or list fields in the UI). In general these types of fields link from one record to another.

Select fields have two components: a value and a text. The value of a Select field is always the internalid of the selected record. The text is always the name of the selected record.

In a Search Result instance (i.e. your searchResults[i]), calling getValue() will return the internalid while calling getText() will return the name.

Wherever you want the display text from a List field, use getText() instead of getValue().