UI actions

saikumarkak
Tera Contributor

i have created the button through ui action on the incident table and named as export csv. here when i click on that button i want to download the incident list in CSV formate. how can i aachieve this.

function exportCSV() {
if (!confirm("Do you want to export the current incident list to CSV?")) {
return;
}

var gr = GlideList2.get('incident');
if (!gr) {
alert('Incident list not found.');
return;
}

var encodedQuery = gr.getQuery();
var view = gr.getView();
var orderBy = gr.getOrderBy();

var exportURL = '/incident.do?CSV' +
'&sysparm_query=' + encodeURIComponent(encodedQuery) +
'&sysparm_view=' + encodeURIComponent(view) +
'&sysparm_order=' + encodeURIComponent(orderBy);

window.location.href = exportURL;
}

 

i wrote this script in ui action script and where the onClick is: exportCSV();

does this script make any sense to achieve my requirement

 

 

6 REPLIES 6

OlaN
Giga Sage
Giga Sage

Also, please avoid to post multiple questions on the same thing.
I just saw that you've already posted this question 30 min earlier...

Ui actions - ServiceNow Community

saikumarkak
Tera Contributor

Ok