
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2013 01:43 PM
This is the first time that this has been attempted as I am a new ServiceNow Administrator but what I am trying to do is get an attached document to open from a link that will automatically download the file once clicked. I made sure that include attachments was selected in the E-mail Notification and also paste this script in the message box. I created a KB article in order to be able to access this file with ease from the following url https://pharmerica.servicenow.com/sys_attachment.do?sys_id=52eeb924b18199444a6d107fb5606025. I am able to copy and paste the link in any web browser and it automatically downloads the file without any issues but I cannot get it to launch from the link located by "Click here to view:" is as it redirects you to the actual request form.
I'm pretty sure this is something simple but any help will greatly be appreciated. 🙂
Short description: ${short_description}
Click here to view: ${URI}
attachLinks();
function attachLinks() {
//Check for any attachments and add attachment links if they exist
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id',current.sys_id);
gr.query();
if(gr.hasNext()){
template.print('Attachments: \n');
while (gr.next()) {
var attachLink = 'https://pharmerica.servicenow.com/sys_attachment.do?sys_id=52eeb924b18199444a6d107fb5606025''%20+%20...
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2013 03:26 PM
Sorry, I attached the code as a text document. The forum translated the html tags instead of displaying them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2013 03:22 PM
You need to call out when you are starting a mail script. Try something like this,
Short description: ${short_description}
attachLinks();
function attachLinks() {
//Check for any attachments and add attachment links if they exist
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id',current.sys_id);
gr.query();
if(gr.hasNext()){
template.print('Attachments: \n');
while (gr.next()) {
var attachLink = '' + gr.file_name + '';
template.print('Click here to view'\n');
}
template.print('');
}
}
Comments:
${comments}
I think that will work, I did something similar in one of our notifications.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2013 03:26 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2013 12:57 PM
This worked after tweaking around the code alittle. Sorry for the late response back but it has been busy here.