RE: SuiteQL export to CSV
If you are doing the conversion in SuiteScript and not through one of the SuiteQL tools, then my favorite tool is PapaParse.
Here’s a (possibly working) example of a function that takes a SQL string and returns the output of the query as CSV:
define(['N/query', './papaparse.min.js'], (query, Papa) => {
/**
@param sqlQuery - string value with valid SQL query
*/
const queryToCSV = (sqlQuery) => {
const mappedResults = query.runSuiteQL({ // If the data set is larger than 4,000 records, then you'll have to use the paged version.
query: sqlQuery,
}).asMappedResults()
const csv = Papa.unparse(mappedResults);
return csv;
}
