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.

How to create Custom Export Excel UI action in Related lists?

Ajay37
Tera Contributor

Hi,

I want to create an Export excel UI action on related lists. Could anyone help me on this?

Thanks

2 REPLIES 2

Kalyani Jangam1
Mega Sage

Hi Ajay, Please refer below code for Custom export excel UI action

find_real_file.png

function downloadExcel(){
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

// this code you can move to script include and go GlideAjax as well
var gr = new GlideRecord('sn_customerservice_case');
gr.addQuery('sys_id', 'IN', rows);
gr.query();
while(gr.next()){
gr.u_exported = true;
gr.update();
}

var view = "default"; // 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.
var dialog = new GwtPollDialog('sn_customerservice_case', query, rows, view, 'unload_excel_xlsx');
dialog.execute();

}

 

Please try this code and let us know if it will helpful

Tiago Duarte
Tera Contributor

Hi,

 

I believe the "Export" option on the Related Lists (advanced view and workspace) should be available out-of-the-box (OOB) in ServiceNow. I have submitted an idea requesting this feature. If you also think this should be available OOB in ServiceNow, please vote on this idea.

 

Thanks