Is there any way can create a text file or CSV fil...
# suitescript
s
Is there any way can create a text file or CSV file in such a pattern by fetching data from a saved search?
c
Well, you might wanna look at the
N/file
module. You can write to a string while iterating your search results and put them in the file and save it.
Once it’s in the file cabinet you can email it to the user, attach it to a record, etc…
s
Do you have some code for this?
var searchResultCount = getJBData.runPaged().count; log.debug("getJBData result count", searchResultCount); getJBData.run().each(function(result) { sono = result.getValue(cols[0]); scmcode = result.getValue(cols[1]); Content = Content + sono + '' + sono ; Content = Content + '\n'; }); var csv = file.create({ name: 'PSI cycle1extract.txt', fileType: file.Type.CSV, contents: Content }); // log.debug('Excel csv created successfully', 'Id: ' + csv); csv.folder = folderId; var csvid = csv.save(); Unable to itrerate properly
c
looks like your
.each()
is missing
return true;
at the bottom of the method.
e
Use the
N/task
module. You can submit a task that will export the results of a search to CSV in the file cabinet.
💯 1