Hi, I am using a saved search task to generate a f...
# suitescript
m
Hi, I am using a saved search task to generate a file to send to the customer at the end of the month.
Copy code
let searchTask = task.create({
  taskType: task.TaskType.SEARCH,
});
searchTask.savedSearchId = srchID;
searchTask.filePath =
  "CustomersMonthlyReports/" +
  year +
  "/" +
  monthNames[month] +
  "/tranid_" +
  invoice.getValue("tranid") +
  "_internalid_" +
  invoiceID +
  ".csv";
searchTask.submit();
Some columns have Arabic text, it looks as in the attached image, you have to do some steps in Excel to view it correctly. I don't want to ask the user to do these steps. I googled the problem, some suggested say you just need to use
utf-8-sig
, but NS doesn't have that. I tried also to save the file as
xls
and
xlsx
but Excel responds with an error for one, and the other doesn't show Arabic text correctly too. Can this be handled using scripts, or it has to be from Excel or Windows? Thanks
a
which encoding are you using?
I don't see what encoding is used by default - do you know what encoding the generated .csv has?
idk if basic utf-8 gets you what you need for arabic characters... and that probably IS the default anyway so the following may be a waste of time, but you're not going to get utf-8-sig out of NetSuite.
instead of using
searchTask.filePath
generate an empty file first with that dynamic path and name and set the encoding on the file to utf-8.
Copy code
//Add additional code 
...
var fileObj = file.create({
    name: fileName,
    fileType: file.Type.CSV,
    encoding: file.Encoding.UTF_8,
    folder: folder,
});
and then run your search task using
searchTask.fileId = fileObj
instead
I'm pretty sure none of the other available encodings will work, so if its already generating utf-8... I have no idea how to help
c
Are you emailing the file for NetSuite? If not you could drop the file into a folder that is watched by Excel Power Query. Then, when the file is added to the folder, Power Query will automatically import the file, clean it up, and save it. There's a few articles on our support site on Power Query. This one shows how to import the files.
m
generate an empty file first
@Anthony OConnor I didn't think of that idea, I was changing the encoding to utf-8 before sending the file. I will try it. Thanks.
👍 1
@Chris Corcoran I am emailing from NS, yeah. Will look into that. Thanks very much.