I am trying to utilize a Saved Search to generate a csv file. My biggest issue is that I have several columns that are formulas. From looking at the API, I need to use the getValue() function which takes 3 params - name, join, summary. My issue is I do not know the "name" of the formula columns. Via the SuiteScript IDE (Eclipse with Plugin) it showed me a "getAllColumns()" function that should return an array of the columns. I also found it in this documentation: https://system.netsuite.com/app/common/scripting/nlapihandler.nl?downloadapi=T However, when I run the script, I get the error "[L.nlobjSearchResult;" has no public instance field or method named "getAllColumns"."
Below is my code. Any recommendations would be great as to how I can get at the names of all the columns easily, including the formulas. I have 38 columns, so would want to loop through them and not just do a getValue('name1') if possible.
function gen_ven(){
var data = '';//this will contain all of the eventual data for this file
var sQF = '"', sDelim = ',';
var results = nlapiSearchRecord('vendor','customsearch_se_ven');
var columns = results.getAllColumns();
for(var i =0;i<results.length;i++)
{
for(var j = 0; j<columns.length; j++){
data += sQF + results[i].getValue(columns[j])+sQF+sDelim;
}
data += '\n';
}
var file = nlapiCreateFile('Vendor.csv', CSV, data);
response.setContentType(file.getType(), 'Vendor.csv');
response.write(file.getValue());
}
I also did try using results.prototype.getAllColumns() but this didn't work at all.
Thank you for any help you can give