Export Excel via UI Action in List View
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2025 03:05 PM
Hi everyone,
I'm trying to implement an Excel export feature via a UI Action in the list view, but the script I've tried it doesn’t work as expected.
[Requirement]
While we’re aware that there is an out-of-the-box Excel export feature available via the list context menu (right-click), our client specifically requires the ability to export records through a UI Action (List Banner Button).
I referred to the following post and tried several script examples:
https://www.servicenow.com/community/developer-forum/how-can-i-replicate-export-as-excel-in-incident...
Here’s the script I’ve attempted to use:
function downloadAllToExcel() {
var tableName = g_list.getTableName();
var query = g_list.getQuery();
var view = new URLSearchParams(window.location.search).get("sysparm_view") || "";
var url = "/export/" + tableName + ".do?CSV" +
"&sysparm_query=" + encodeURIComponent(query) +
"&sysparm_view=" + encodeURIComponent(view);
window.location.href = url;
}
However, when I click the button, I get the following error in the console:
Uncaught TypeError: Cannot read properties of null (reading 'location')
at downloadAllToExcel
at HTMLButtonElement.onclick
Has anyone encountered a similar issue or know how to properly implement this export function via a UI Action?
Any guidance would be greatly appreciated!
Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2025 07:14 PM
Hi @Kim46 ,
You can check this link :
https://www.quora.com/How-do-I-create-a-custom-export-Excel-UI-action-in-related-lists
Sandeep Dutta
Please mark the answer correct & Helpful, if i could help you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2025 07:47 PM
what debugging did you do?
did you add alert and see?
If my response helped please mark it correct and close the thread so that it benefits future readers.
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-02-2025 11:28 PM
Thank you for replying to my question. In the end, I was able to implement it. But only xls file.
Here's it.
function outputExcel() {
var viewName = '<view name>’;
var url = “<table name>_list.do?EXCEL&export_format=xlsx&sysparm_view=" + viewName;
g_navigation.open(url);
}