- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2014 04:01 PM
hey guys,
I am trying to setup an email notification to send out to users after the submit a ticket to request for an item in our Service Catalog.
I have it working within the workflow so that the user goes to the Catalog, finds the item, clicks submit, and then the workflow automatically completes the request (as it does not require approval) and sends the user an email notification which I would like to include a hyperlink to the file I wish for them to access.
Where I am getting stuck is the email. It sends out to the user fine, but the network share that I would like for them to be able to simply click on doesn't actually link.
Is there some scripting that I can implement to achieve this? The file I wish for them to access is a self-installer that will be located on a local server (think \\servername\folder\file.exe\
The other alternative would be to attach the file in question, but I can't seem to figure out how to do this.
Are either of these options possible?
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2014 02:16 PM
Ok, this may or may not work:
<mail_script>
template.print('<a href="http://instancename.service-now.com/scs/airparrot%20install_aus.exe" download>Download Link</a>');
</mail_script>
This is using an HTML5 "download" attribute which essentially forces the client to perform a save as on the link. It is supported in Firefox, Chrome, and Opera but not Safari and IE. I don't know how email clients will handle it. The problem is if the client doesn't support the download attribute, you will get a 404 page or some other Resource Unavailable message.
If you run into this, the only solution is to upload the file in a different way. You can upload it to ServiceNow as a Knowledge Attachment or attachment to any other record. But this is the only way to get it stored on the sys_attachment table. Then you could use the following script in the notification:
<mail_script>
var sysIdOfAttachment = 'sys_id of the sys_attachment record you uploaded here';
var userFriendlyName = 'This is what the user will see/click in the email';
template.print('Attachment: <a href="http://instancename.service-now.com/sys_attachment.do?sys_id=' + sysIdOfAttachment + '">' + userFriendlyName + '</a>\n');
</mail_script>
Edit: Sorry for the edits, Community was not letting me post because of a gs.getProperty("instance_name") line.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2014 10:30 AM
Hi Vlad,
I believe the problem is the local file address. Mail Clients and Web Browsers have been tightening restrictions on local file links in recent years to prevent security breaches. They have created very isolated sandboxes to protect your computer from the web.
That said, you have two options that I would recommend:
1. Use a web addressable protocol (instead of file://) such as ftp, http, https, etc. This of course requires your file to exist on a server that supports these protocols.
a. One way of doing this is to use ServiceNow. You can upload the file to ServiceNow as an attachment to a Knowledge Article and mark the KB as Attachment Link. Then when you direct a user to the KB url, it should download the attachment as the default behavior.
2. Upload the file as an attachment elsewhere in ServiceNow and then Include Attachments in an Email Notification - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2014 12:11 PM
Hi Travis,
Thanks for the reply.
So I have elected to try with the attachment route.. your #2 option.
I have uploaded the file to our DEV instance and have a URL to it.. I'm a bit confused on the script however..
Here is what I placed:
<mail_script>
printattachments();
function printattachments() {
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id',current.sys_id);
gr.query();
while (gr.next()) {
template.print('Attachment: <a href="https://*ourinstance*.service-now.com/scs/airparrot%20install_aus.exe'
+ gr.sys_id + '">' + gr.file_name + '</a>\n');
}
}
</mail_script>
When I look at the email sent it doesn't include an attachment and shows nothing in the body.. I've very unknowledgable with scripting stuff in SN, so I imagine I didn't do this right.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2014 01:26 PM
It depends on how you uploaded the file into ServiceNow. Which approach did you use?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2014 01:28 PM
I went into system definition > upload file. It then gives a link which I right clicked and copied shortcut.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2014 02:16 PM
Ok, this may or may not work:
<mail_script>
template.print('<a href="http://instancename.service-now.com/scs/airparrot%20install_aus.exe" download>Download Link</a>');
</mail_script>
This is using an HTML5 "download" attribute which essentially forces the client to perform a save as on the link. It is supported in Firefox, Chrome, and Opera but not Safari and IE. I don't know how email clients will handle it. The problem is if the client doesn't support the download attribute, you will get a 404 page or some other Resource Unavailable message.
If you run into this, the only solution is to upload the file in a different way. You can upload it to ServiceNow as a Knowledge Attachment or attachment to any other record. But this is the only way to get it stored on the sys_attachment table. Then you could use the following script in the notification:
<mail_script>
var sysIdOfAttachment = 'sys_id of the sys_attachment record you uploaded here';
var userFriendlyName = 'This is what the user will see/click in the email';
template.print('Attachment: <a href="http://instancename.service-now.com/sys_attachment.do?sys_id=' + sysIdOfAttachment + '">' + userFriendlyName + '</a>\n');
</mail_script>
Edit: Sorry for the edits, Community was not letting me post because of a gs.getProperty("instance_name") line.