- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2022 06:56 AM
I want to create List view UI action where the user can download a specific Excel File.
I'm trying to create a function but it seems to be not working or giving any response when the button is clicked.
The same ui action if I've not checked on client and without a function is working but I have to select a record which I don't want.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2022 05:05 AM - edited ‎11-01-2022 05:06 AM
Then use below script in UI Action.
onClick = confirmDownload()
function confirmDownload() {
var URL = '<Link_Of_Attachment>';
var down = confirm('Do you want to download the file?');
alert(down);
if (down) {
g_navigation.openPopup(URL);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2022 07:08 AM
Can you post your code and a screenshot of your UI action settings?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2022 01:10 AM
Hi Mike,
There you go
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2022 02:47 AM - edited ‎10-27-2022 02:50 AM
If you navigate to System UI > UI Context Menus, and search for Excel in Name column, open any record as per your need, there you will find script which might work for you. See the below image for reference.
So, your UI Action Script would be like below.
Client: Checked
onClick: confirmExport()
function confirmExport() {
var down = confirm('Do you want to download the file?');
alert(down);
if (down) {
var exportHandler = new ContextMenuExportHandler(g_list, 'unload_excel_xlsx');
exportHandler.exportRecords();
}
}
First it will be exported, then you will have a button to either download or cancel. One more thing, instead of using download as a function name, try with some other name.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2022 10:24 PM
Thanks for the response but I wanted to download a particular file which I have uploaded to servicenow and I do have the file link for that. With your code it's exporting the records of the table.