Not able to download Suitelet through suitescript 1.0

279 views Asked by At

I have created a button to export the form data to simple Excel. Everything is working file, even if i try to save this excel file in the file cabinet it gets saved correctly. But when i try to downlaod the excel file, downloads wierd single cell file with special characters or system gives either an error or saves an empty excel file. Can anyone help me in how to download the excel file from button click. I think i have issue in my responce.

My Code example is as follows:

  .
  .
  .
  xmlString += '</Table></Worksheet></Workbook>';// this is my xml string

  var xlsFile = nlapiCreateFile('test.xls', 'EXCEL', nlapiEncrypt(xmlString, 'base64'));
  response.writeFile(xmlFile);
}

error screenshot:

enter image description here

1

There are 1 answers

3
Albert Fermo On

I think the reason for the response issue is because you are calling a non-existent variable "xmlFile" in writeFile();

try using this writeFile(xlsFile);