
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2019 07:39 AM
There are 240 incidents that we need to PDF and send do someone. Instead of doing it one by one as we need the export to be of the form is there a way to export each incident as a PDF via a script?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2019 01:51 PM
I think I figured out something in ServiceNow so that it create the PDFs and attaches them to record I created in another table as we do not want them attached to the incident record. I'm also able to set the name so it is not just incident.pdf. Here is what I did.
1. Created a custom table with only 1 string value called number. (this will get the number from the incident table).
2. Created 2 system properties with the admin user name and password.
3. Created a scheduled that is set to is run on demand with the following code.
var gr = new GlideRecord('incident');
gr.addEncodedQuery('query string');
gr.query();
while (gr.next()){
var incPDF = new GlideRecord ('u_incident_to_pdf');
incPDF.initialize();
incPDF.u_number = gr.number;
var sysID = incPDF.insert();
var rm = new sn_ws.RESTMessageV2();
rm.setHttpMethod('GET');
var url = gs.getProperty('glide.servlet.uri') + 'incident'+ '.do?PDF&sys_id=' + gr.sys_id;
rm.setEndpoint(url);
// Create new properties and save user id and password of an admin account
rm.setBasicAuth(gs.getProperty('glide.user.userid'), gs.getProperty('glide.user.password'));
rm.saveResponseBodyAsAttachment('u_incident_to_pdf',sysID,gr.number+'.pdf');
var response = rm.execute();
}
Someone still has to go in and manually download each PDF but at least they do not have to rename them and then once they are done there is just a little clean up of deleting that attachment and the record in the table so it can be reused at a latter date and we are not clogging up ServiceNow with the no longer needed attachments.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2019 08:14 AM
Hi,
Why would you need PDF of each incident if only some of the fields can give you valuable information.
Put valuable information like INC Number, SHort descption,Description,Priority and export it by
https://devxxx.service-now.com/incident_list.do/?PDF
it will give you list .
or if you want all information of the incident why not create a Report keep all the fields of the incident there
and download it
https://community.servicenow.com/community?id=community_question&sys_id=d14fcbe1dbdcdbc01dcaf3231f961906
Mark my ANSWER as CORRECt and HELPFUL if it helepd

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2019 08:19 AM
They want the PDF of each incident so they have an easy to read format for work note and comments. List layout does not work in this case.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2019 08:57 AM
Hello Brian,
This is not recommended. You can export a table in PDF, Excel CSV with maximum 25 columns and the columns values will be hardly readable. See screenshot below:
In order to create a PDF for each record, you should first click on it then export it to PDF which is not feasible for your case as you have too many records.
See the doc for more details about the types of exports available in Service Now: https://docs.servicenow.com/bundle/london-platform-administration/page/administer/exporting-data/con....
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2019 10:05 AM
A list in excel is not feasible either. I need work notes and comments adding that filed "comments and work notes" is not readable as the field is to big.