Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Generate Excel from record

Rosy14
Kilo Sage

Hi,

 

I have a record producer. I want to generate a excel of the submitted values after submitting the record. how to do?

5 REPLIES 5

Hi,

I have tried below script.. but not working.. 

ar fileName = 'Test.xls';
var Headers = ["Article Number", "Item Number", "Crushable"];
var xlsData = '';
for (var i = 0; i < Headers.length; i++) { //Build the Headers
    xlsData = xlsData + '"' + Headers[i] + '"' + ',';
}
xlsData = xlsData + "\r\n";
for (i = 0; i < rowsInt; i++) {
    xlsData = xlsData + '"' + "" + '",' + '"' + producer.crushable_change_request.getRow(i).item_number + '",' + '"' + producer.crushable_change_request.getRow(i).crushable;
    xlsData = xlsData + "\r\n";
}
//attach the file to a record.
var grAttachment = new GlideSysAttachment();
grAttachment.write(current, current.number+'.xls','test/csv', xlsData);