Search code examples
netsuite

NetSuite custom customer center - Saved saved - show all customers of a category


I am building a customer center ssp application and i need to create a saved search to show all customers of a particular category.

For this I need Lists -> Customers permission to this customer center role, but apparently we cannot do it.

  • What is a relevant ss file code for this saved search? or
  • Is there another way to do it?

Solution

  •     function export(){
        var results = nlapiSearchRecord('customer', 2830); //rec type, search id
        var header = new Array();
        var row = new Array();
        header[0] = 'name'; // search column headers, # is the numeric order of the column, text is the text displayed as header in the export
        header[3] = 'class';
        var data = header + '\n';
            for (i = 0; i < results.length; i++){
                var result = results[i];
                var columns = result.getAllColumns();
                row[0] = result.getValue(columns[0]); // retrieving search result line data for column 0 in search
                row[3] = result.getText(columns[3]); // column 3's line data
            data += row + '\n';
        }
        var file = nlapiCreateFile('customerdata.csv', 'CSV', data); //csv detail
        response.setContentType(file.getType(), 'customerdata.csv'); //exports csv for user
        response.write(file.getValue());  
    }