How to create PDF file by script from record and attache the file to Record.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2023 07:16 PM - edited 07-10-2023 07:18 PM
【Script I used】
// This is where we'll save the attachment
var tablename= 'incident';
var recordSysId = 'ed92e8d173d023002728660c4cf6a7bc';
var filename = 'snlogo.png';
// Let's download the ServiceNow Logo
//var logoUrl = 'https://MyInstance.service-now.com/images/logos/logo_service-now.png';
var logoUrl =gs.getProperty("glide.servlet.uri") + 'incident' + '.do?PDF&sys_id=' + 'ed92e8d173d023002728660c4cf6a7bc';
var logoUrl ="https://MyInstance.service-now.com/incident.do?PDF&sys_id=ed92e8d173d023002728660c4cf6a7bc"
gs.info(logoUrl);
var request = new sn_ws.RESTMessageV2();
request.setHttpMethod('get');
request.setEndpoint(logoUrl);
I used this script and it returned 401.
Please let me know what the fix is.
// Configure the request to save the response as an attachment
request.saveResponseBodyAsAttachment(tablename, recordSysId, filename);
// When we execute the request, the attachment will automatically be
// saved to the record we specified
var response = request.execute();
var httpResponseStatus = response.getStatusCode();
var httpResponseContentType = response.getHeader('Content-Type');
gs.debug("http response status_code: " + httpResponseStatus);
gs.debug("http response content-type: " + httpResponseContentType);
I used this script and it returned 401.
Please let me know what the fix is.
Please let me know what the fix is.
thank you all.
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2023 10:31 PM
error 401 means incorrect username and password. please check that once
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader