Need to add an export button on a dashboard where it exports all the records on a table to excel

Maradani Revat1
Tera Contributor

I have a requirement to add an "Export button" on a dashbord. when we click on the button it should export all the records on the table.Can anyone help me how can we add a button on dashboard

3 REPLIES 3

Kalyani Jangam1
Mega Sage

Hi @Maradani Revat1 

Try below code in UI action

 

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 check and let me know if it helpful or not.

hi @Kalyani Jangam1 ,

 

Thank you for the reply. will this ui action be displayed on dashboard?

Kalyani Jangam1
Mega Sage

Hi @Maradani Revat1 

You can achieve this like below. You can create UI action in "pa_dashboard" table and it look like similar

Screenshot 2022-12-06 at 11.06.35 AM.png

Once we click this link it export all dashboard related record in excel sheet. This only way it will possible in dashboard button will not appear.

 

Please check and Mark Helpful or Correct if it helps you.