- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 05-27-2020 09:51 AM
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://<instance_name>.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.