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
‎08-18-2017 06:01 AM
Hi Ashwani,
yes you can.
You want it to export all the records or only the ones which user has selected from the checkbox.
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2020 09:38 AM
Hi Ankur,
Only the ones which user has selected from the checkbox.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2017 02:21 AM
Hi Ashwini,
Any update on this?
Can you mark my answer as correct, helpful and hit like if you were able to achieve the requirement. This helps in removing this question from unanswered list and helps users to learn from your thread. Thanks in advance.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-18-2017 10:49 PM
Hi Ashwani,
This is possible you can use the below code in custom UI action under list view to achieve the same.
Steps:
Create a UI Action of List Choice Type,
Use the below code in script field.
function exporttoExcel() {
var sysparm_rows = g_list.grandTotalRows;
var num_rows = parseInt(sysparm_rows);
var selSysIds = g_list.getChecked(); // This will return the sys_id of the selected records
var sysIdList = selSysIds.split(',');
var sysparm_query = "";
for(var i=0; i<sysIdList.length; i++) {
if(sysparm_query != "") {
sysparm_query = sysparm_query +"^OR" +"sys_id=" +sysIdList[i]; // Passing sys_ids to sysparm_query
} else {
sysparm_query = "sys_id=" +sysIdList[i];
}
}
var tableName = 'incident'; // Table Name for which the records needs to be exported
var sysparm_view = g_list.view;
// If the records are less then export threshold GwtPollDialog will export the records in .xls format
if (num_rows < g_export_warn_threshold) {
var dialog = new GwtPollDialog(tableName, sysparm_query, sysparm_rows, sysparm_view, 'unload_excel_xls');
dialog.execute();
return;
}
// If the records are more then export threshold GwtExportScheduleDialog will export the records in .xlsx format
var dialog = new GwtExportScheduleDialog(tableName, sysparm_query, sysparm_rows, sysparm_view, 'unload_excel_xls');
dialog.execute();
}