<script custom-tag="" type="application/ld+json">{"@context":"https://schema.org","@type":"TechArticle","headline":"How to open a PDF attachment without downloading using a User Interface Macro","image":"http://support.servicenow.com/29f1d2661baf6010cafa53d8624bcb43.iix","author":{"name":"ServiceNow Support","url":"http://support.servicenow.com/now"},"keywords":"ServiceNow, NowSupport public Knowledge Base articles, Support and Troubleshooting,KB0724964,","wordcount":"230","publisher":"ServiceNow","url":"https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0724964","datePublished":"2019-01-29","dateCreated":"2019-01-28","dateModified":"2023-02-22","description":"<h2>How to open a PDF attachment without downloading using a User Interface Macro</h2><br/><div style=\"overflow-x:auto\"><article><div ><h3 >Description</h3><section><p>This knowledge base article prov","articleBody":"<h2>How to open a PDF attachment without downloading using a User Interface Macro</h2><br/><div style=\"overflow-x:auto\"><article><div ><h3 >Description</h3><section><p>This knowledge base article provides guidance on how to view a PDF attachment through the use of a UI Macro, without the need to download the file.</p>\r\n<h3>Procedure</h3>\r\n<ul style=\"list-style-position: inside;\"><li>To begin with, set the system property <strong>'glide.ui.attachment.force_download_all_mime_types'</strong> as <strong>'False'</strong>.</li><li>This enables to view an attachment by simply clicking on the 'view' button without the need to download the attachment.</li><li>Next, create a User Interface Macro with the following script (for instance, you can name the UI Macro as 'test_link'): <br /><br /></li></ul>\r\n<pre><code><?xml version="1.0" encoding="utf-8" ?><br /><br /><j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null"><br /><br /><j:set var="jvar_use_doc_viewer" value="${gs.getProperty('glide.knowman.use_document_viewer', false) == 'true' ? pm.isActive('com.snc.documentviewer') : false}"/><br /> <br /> <j:if test="${jvar_use_doc_viewer == 'true'}"><br /><br /> <a href='/sys_attachment.do?sysparm_referring_url=tear_off&amp;view=true&amp;sys_id= <sys_id>'><display_name_of_file>.pdf</a><br /><br /> </j:if><br /><br /></code><code></j:jelly></code><span style=\"font-family: 'courier new', courier;\"><code><br /><br /></code></span></pre>\r\n<p> </p>\r\n<p>To implement this User Interface Macro on a specific field in a form, adjust the dictionary settings of the relevant field and add the attribute <strong>'ref_contributions=<name of UI Macro>'</strong> (in this example, it would be <strong>'ref_contributions=test_link'</strong>). Once you have added this attribute, clicking on the User Interface Macro in the form enables to directly open the PDF attachment on the same window, without the need to download the file.</p></section></div><div ><h3 >Additional Information</h3><section><p><a title=\"Available System Properties\" href=\"https://docs.servicenow.com/csh?topicname=r_AvailableSystemProperties.html&version=latest\" target=\"_blank\" rel=\"noopener noreferrer\">Available System Properties</a></p></section></div></article></div>"}</script>