Create CSV file in NetSuite

Store the customer details into variables and set details to the csvContent variable and assign the content to the contents.

                    let customer = orderDetails[0].entity;
                    let email = orderDetails[0].email;
                    let tranid = orderDetails[0].tranid;
                    let amount = orderDetails[0].amount;
                   
                    csvContent += '"' + customer + '","' + email + '","' + tranid + '","' + amount + '"\n';
    var csvFile = file.create({
                    name: 'LastMonthCustomersSalesReport'+ salesRepId + '.csv',
                    fileType: file.Type.CSV,
                    contents: csvContent,
                    folder: '7' // Replace 'folderId' with the actual folder internal ID
                });
 
                // Save the file
                var fileId = csvFile.save();

Leave a comment

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