logo

NJP

Attach record PDF file to email notification

Import · May 27, 2020 · article

In order to auto attached a PDF field with email notification, you will need to create a Business Rule (or Script Include) with the following:

When to run: After Insert

Advanced: true

Script:

(function executeRule(current, previous /*null when async*/) {

var rm = new sn_ws.RESTMessageV2(); rm.setHttpMethod('GET');

var url = 'https://.service-now.com/' + current.target_table + '.do?PDF&sys_id=' + current.instance;

rm.setEndpoint(url);

rm.setBasicAuth(gs.getProperty('sys.properties.userid'), gs.getProperty('sys.properties.password'));

rm.saveResponseBodyAsAttachment(current.getTableName(), current.sys_id, current.target_table +".pdf");

var response = rm.execute();

})(current, previous);

Do not forget to create 2 system properties for User ID ('sys.properties.userid') and for Password ('sys.properties.password') and give them the currect value.

Labels:

image

View original source

https://www.servicenow.com/community/developer-articles/attach-record-pdf-file-to-email-notification/ta-p/2320563