A link to an attachment from where the user should open the file and view it directly

Aerial Reptile
Giga Expert

Hi there!

 

I have a UI page from where I must provide a link to open the file which was attached in the ticket (excel, pdf etc.). When I do the following-

<a style="color:blue;display:inline;" target="_blank" href="https://mydev.service-now.com/sys_attachment.do?sys_id=${attachment.sys_id}">View File</a>  
where ${attachment.sys_id} is the attachment sys id and it is dynamically set,
it creates a link which downloads the file directly.
 
I don't want this to download the file but instead I'd like for it to open the file directly.
 
Any ideas how this can be achieved?
 
Thanks in advance!
-A.R.
7 REPLIES 7

Robert H
Mega Sage

Hello @Aerial Reptile ,

 

Please use this href attribute value:

"/sys_attachment.do?view=true&sys_id=${attachment.sys_id}"

 

Please also make sure that the System Property "glide.ui.attachment.force_download_all_mime_types" is set to "false".

 

This might not work for all file types but I have verified that it works for PDF files.

 

Regards,

Robert

Aerial Reptile
Giga Expert

Thank you for your reply, Robert!

 

I've modified the line as mentioned and I'm facing this error - The reference to entity "sys_id" must end with the ';' delimiter.

 

Ankur Bawiskar
Tera Patron
Tera Patron

@Aerial Reptile 

enhance as this from previous reply

"/sys_attachment.do?view=true&amp;sys_id=${attachment.sys_id}"

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ankur Bawiskar
Tera Patron
Tera Patron

@Aerial Reptile 

this link explains about the properties

Attachments prompting to be downloaded rather than opening directly when clicking "view" 

AnkurBawiskar_0-1744359021800.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader