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.

Rename the excel file when exporting

tanz
Tera Expert

Hi,

 

I have this script which is working fine in export . I want to rename the file before I click on download button

var checked = g_list.getChecked(); // get's the sys_id of the checked records
        var query = "sys_idIN" + checked.toString();
        var rows = checked.split(",").length; // rows to be sent to the export function
        var view = "x_amspi_in_ewaybilltemplate_bulkupload"; // set this to default for columns present in default view for list layout
        // set this to empty if you want all the columns present in the list layout including the customized ones.
        if (rows <= 50) {
            var dialog = new GwtPollDialog('x_amspi_in_ewaybilltemplate_bulkupload', query, rows, view, 'unload_excel_xlsx');
            dialog.execute();
        } else if (rows > 50) {
            alert('Please be Informed that Number of records selected can not be more than 50');
            g_list.refresh();
        }
 
I want to rename the file as Ewaybilltemplate_bulkupload and instead of Page1 it will be Eway bill
3 REPLIES 3

Yashsvi
Kilo Sage

Hi @tanz,

please check below script:

var checked = g_list.getChecked(); // get the sys_id of the checked records
var query = "sys_idIN" + checked.toString();
var rows = checked.split(",").length; // rows to be sent to the export function
var view = "x_amspi_in_ewaybilltemplate_bulkupload"; // set this to default for columns present in default view for list layout
// set this to empty if you want all the columns present in the list layout including the customized ones.

if (rows <= 50) {
    var dialog = new GwtPollDialog('x_amspi_in_ewaybilltemplate_bulkupload', query, rows, view, 'unload_excel_xlsx');

    // Set the file name
    dialog.setOption('file_name', 'Ewaybilltemplate_bulkupload.xlsx');

    // Set the sheet name
    dialog.setOption('sheet_name', 'Eway bill');

    dialog.execute();
} else if (rows > 50) {
    alert('Please be informed that the number of records selected cannot be more than 50');
    g_list.refresh();
}

Thank you, please make helpful if you accept the solution. 

Hi @Yashsvi ,The dialog box is not working now.

tanz_0-1720507165320.png

 

Sid18
Tera Contributor

Facing same issue