How can I replicate Export as Excel in incident from list view?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2017 05:48 AM
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
- Labels:
-
Best Practices
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2021 08:36 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2021 02:09 AM
Hi
Thanks, it worked with some changes in code.
Thanks,
Shradha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2024 11:55 PM
thanks very much!!
and how to capture if 'Cancle' button is clicked...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2018 07:03 AM
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