How can I get to the PDF of printer friendly version from the server side script?

Junichi Kaneda
Kilo Expert

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.

3 REPLIES 3

premer
Giga Expert

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();

@premer 

Thank you for your reply.

But, my question is about PDF of "printer friendly version", which can be generated from user preference popup (below).

I need to include variables of Requested Item in PDF.

find_real_file.png

hi, 

Is the requirement accomplished?