Cloud Stack Ninja

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);
}

}


Read more here: https://stackoverflow.com/questions/64414333/for-some-reason-the-subsidiary-entityid-payablesaccount-exoenseaccount-are-ex

Content Attribution

This content was originally published by Nilesh Pandey at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: