- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2017 09:47 PM
Hi All,
I want to generate a PDF of selected records in a list, when the user clicks on 'Generate PDF' UI action(List Choice),created by me.
Is there a way I could do this.
Thanks,
Trinadh.Developer Community Service ManagementdvpChuck Tomasi's BlogPradeep Sharma's Blog ctomasi
Solved! Go to Solution.
- 5,566 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2017 01:59 AM
Hi Trinadh,
Have a List UI Action either List bottom button or List context menu as per your need.
Select the checkbox for client and add this function downloadPdf()
In the script section add the following code. What it does is it gets the pdf for only those records which are selected in the list layout.
I have tested it at my end and is working fine. It will take columns specific to a view and not the ones which you have added from gear icon.
If you want the columns which are present on the list layout then make the view as empty
Script
function downloadPdf(){
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; // rows to be sent to the pdf function
var view = "default"; // set this to default for columns present in default view for list layout
//var view = ""; // set this to empty if you want all the columns present in the list layout including the customized ones.
var dialog = new GwtPollDialog('u_sample_table', query, rows, view, 'unload_pdf');
dialog.execute();
}
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
‎02-17-2017 03:08 AM
Hi Ankur,
That worked fine.
Thanks for the assistance overall.
Thanks,
Trinadh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2017 04:48 AM
Hi Ankur,
I am also trying to achieve something similar. I wanted to download Image in my incident as PDF. Can you pls assist.
Thanks In Advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2020 02:13 PM
I was able to create an export selected to xml list choice using your script and just changing the pdf to xml. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2020 10:02 PM
Thanks for the update.
Do remember to mark appropriate responses as helpful.
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
‎11-19-2023 10:04 PM
Hi @Ankur Bawiskar ,
I was using your code in UI Builder list action to export only selected rows but getting below error :
Code :
try {
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; // rows to be sent to the pdf function
var view = "workspace"; // set this to default for columns present in default view for list layout
var dialog = new GwtPollDialog(g_list.tableName, query, rows, view, 'unload_pdf');
dialog.execute();
} catch (ex) {
var message = ex.message;
alert("Error in system logs: " + message);
}
Is there anything which I missed here ? It is working fine from backend list view but not working in UI builder workspace.