How can I replicate Export as Excel in incident from list view?

ashwanikumar
Tera Expert

Hi All,

Is it possible to create a new custom UI Action on incident list view to replicate Export as an Excel?

If yes then how can I proceed?

Thanks,

Kumar

13 REPLIES 13

Hi, I now know how this works  a lot better and adjusted it to my use case

Remember to on the UI action form have "List v2 Compatible" and "Client" set to true

And also the name of the function in the "Onclick" field

This is UI action code

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;	
var view = "Administration";

 var ga = new GlideAjax('ExportingTaxi');
    ga.addParam('sysparm_name', 'markExported');
    ga.addParam('sysparm_query', query);
    ga.getXML(processResponse);
    
    function processResponse(response) {
    var result = response.responseXML.documentElement.getAttribute("answer");
    }

var dialog = new GwtPollDialog('x_356387_taxiorder_taxi_order', query, rows, view, 'unload_excel_xlsx');
dialog.execute();
}

 

And for the Script include form remember to have "Client callable" set to true

This is the script include code

var ExportingTaxi = Class.create();
ExportingTaxi.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
	
markExported :function() {
	
var query = this.getParameter('sysparm_query');
var task = new GlideRecord('x_356387_taxiorder_taxi_order');
task.addEncodedQuery(query);
task.query();
task.setValue('exported' , true);
task.updateMultiple();
},

    type: 'ExportingTaxi'
});

 

NOTE you will have to adjust the tables and query parameters for your use case.

Feel free to ask more if you need help and please mark helpful if this was indeed helpful.

Hi @harun.isakovic 

 

 

Thanks, it worked with some changes in code.

 

Thanks,

Shradha

 

thanks very much!!

and how to capture if 'Cancle' button is clicked...

Hi.


With the addition of an else-statement at the end, this works perfectly 🙂



Does anyone know if it is possible to handle the generated file as an attachement? I would like to add it to a record.



Thanks


/Steen