How can I get to the PDF of printer friendly version from the server side script?
This content was last updated in 2022. It may still be useful, but could contain outdated information. Please confirm its accuracy before relying on it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2020 01:15 AM
How can I get to the PDF of printer friendly version from the server side script?
I want to automatically attach the printer friendly PDF to the record as an attachment.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2020 07:01 AM
This is the way we did this for our incidents. You basically call the rest api of your own instance to return a printer friendly pdf file of the record, and then save it to the current record. You have to create a basic authentication profile first though in the sys_auth_profile_basic.list menu, and use that sys_id in the setAuthenticationProfile step.
var setName = current.short_description.match(/Request For(.*)$/)[1].trim();
var rest = new sn_ws.RESTMessageV2();
rest.setHttpMethod("GET");
rest.setEndpoint("https://"+gs.getProperty('instance_name')+".service-now.com/"+current.sys_class_name+".do?PDF&sys_id="+current.sys_id+"&sysparm_view=default");
rest.setAuthenticationProfile('basic','sys_id of profile');
rest.saveResponseBodyAsAttachment(current.sys_class_name, current.sys_id,setName);
var response = rest.execute();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2020 09:07 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2022 06:28 AM
hi,
Is the requirement accomplished?