Suitelet to add more functionality and features to custom report:
Export to CSV or Excel
var csvContent = ‘Sales Order,Customer,Date,Total Amountn’;
salesOrderSearch.run().each(function(result) {
csvContent += result.getValue(‘tranid’) + ‘,’ + result.getText(‘entity’) + ‘,’ + result.getValue(‘trandate’) + ‘,’ + result.getValue(‘total’) + ‘n’;
return true;
});
context.response.setHeader({
name: ‘Content-Type’, value: ‘text/csv’
});
context.response.setHeader({
name: ‘Content-Disposition’, value: ‘attachment; filename=”sales_report.csv”‘
});
context.response.write(csvContent);
Generate PDF reports using the N/render module
var renderer = render.create();
renderer.templateContent = ‘<pdf><body>’ + reportHTML + ‘</body></pdf>’;
var pdfFile = renderer.renderAsPdf();
pdfFile.name = ‘sales_report.pdf’;
context.response.writeFile(pdfFile);