Skip to content
thesnowmonk.com

thesnowmonk.com

Servicenow Tips, Tricks and More.

Menu
  • Home
  • About
  • Contact Us
Menu

Download link…If only you were out of the box

Posted on April 7, 2022April 8, 2022 by Arun

Okay, right off the bat, I need to apologize for the terrible post title…I tried 😪

Having said that, let’s get straight to it. In this post, we’re going to explore a very simple trick that I learnt whilst working on a use case and wondered – man why didn’t Servicenow default this already?! Alright, without further ado, I am talking about introducing a download link in your list view for ticket attachments.

Download Link Reference

As you may have noticed in the list view, the download link gets rendered for incidents that have an attachment tied to the form. So how do I get this rad download link on my list?! I’m glad you asked.

Form Setup

For the purposes of this post, I will be setting this up on the incident form. First things first, create a URL type field called ‘Download Link’.

Now, the fun bit…you’re going to dynamically generate this link, if there exists an attachment for the incident in question.

Calculated Value

Configure dictionary on the ‘Download Link’ field, select ‘Advanced View’ in the related list. In the ‘Calculated Value’ tab, check the ‘Calculated’ field, which reveals a Calculation script. Key in the following script,

(function calculatedFieldValue(current) {
    
    var table_sys_id;
    var gr = new GlideRecord('sys_attachment');
    if(gr.get('table_sys_id', current.sys_id)) {
		table_sys_id = gr.sys_id+'';
	}
    else {
		return '';
	}
    var downloadLink = 'https://devxxxxx.service-now.com/sys_attachment.do?sys_id='+table_sys_id;
    return downloadLink;
	
})(current);

Styling the download link

I figured we needed to add a bit of zing to the link itself, right click the ‘Download Link’ field, select ‘Configuration Styles’.

Create a new style for the field, here’s my setup

Oh just a side note here, you need to have an icon pre-loaded (in this instance I’ve called it download_icon.png). I’m pasting the only CSS I’m using,

background-image: url('download_icon.png');
background-repeat: no-repeat;
background-size: 12px 12px;

and there you go folks, you’re very own download link,

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

About This Site

This site is developed and maintained by a ServiceNow developer just like you! An ardent snowhead who is giving you tried and tested tips, tricks and other snippets to get you ahead of the game.

©2025 thesnowmonk.com | Built using WordPress and Responsive Blogily theme by Superb