Export table list as Excel and store it sys_attachment table

DhanakoddiT
Tera Contributor

Hello Team,

 

 I have a requirement as below,

 

Whenever user selects exports .xlsx/.csv from case list> File should be opened directly in google sheets when user clicks "Download" button.

 

So I have created new context menu action and updated below script.

 

rungSheet();

function rungSheet() {
    var exportHandler = new ContextMenuExportHandler(g_list, 'unload_excel_xlsx');
    exportHandler.exportRecords();  
    var ga = new GlideAjax('global.GoogleSheetUtils');
    ga.addParam('sysparm_name', 'creategSheet');
    ga.getXMLWait();
    var answer = ga.getAnswer();
    var url = new GlideURL(answer);
    window.location = url.getURL();
}
 
And in the Script include I am processing the sys_attachment table to get the recently downloaded file from the sys_poll table name.
DhanakoddiT_0-1712917571357.png

But before downloading the attachment the script include was called and processed. So it is not navigating to the Google Sheet created.

 

Anyone know how to add wait condition in context menu to allow user to download and after that call the script include? 

 

Or if we can achieve this requirement using any other ways please help me on this.

 

Thank you!

 
0 REPLIES 0