<script custom-tag="" type="application/ld+json">{"@context":"https://schema.org","@type":"TechArticle","headline":"'Add Attachment' button on catalog that works on both request catalog item form and RITM form.","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,KB0791202,save,Attachment,macro, ui, catalog,RITM","wordcount":"217","publisher":"ServiceNow","url":"https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0791202","datePublished":"2019-12-29","dateCreated":"2019-12-28","dateModified":"2022-05-20","description":"<h2>'Add Attachment' button on catalog that works on both request catalog item form and RITM form.</h2><br/><div style=\"overflow-x:auto\"><article><div ><h3 >Summary</h3><section><p>This article descri","articleBody":"<h2>'Add Attachment' button on catalog that works on both request catalog item form and RITM form.</h2><br/><div style=\"overflow-x:auto\"><article><div ><h3 >Summary</h3><section><p>This article describes on how to create a UI macro type variable to attach attachments. This works on both the request catalog form and the RITM form.</p>\r\n<p> </p></section></div><div ><h3 >Release</h3><section><p>All Versions</p></section></div><div ><h3 >Instructions</h3><section><p>1) Navigate to System UI > UI macros<br />2) Click New.<br />3) Provide a Name such as Add_Attachment_Var.<br />4) In the XML section, copy the paste the following</p>\r\n<p><span style=\"background-color: #000000; color: #ffffff;\"><?xml version="1.0" encoding="utf-8" ?></span><br /><span style=\"background-color: #000000; color: #ffffff;\"><j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null"></span><br /><span style=\"background-color: #000000; color: #ffffff;\"><button style="background: #C0C0C0; border-color: darkgrey; color: #3f464f; height:30; width:70"</span><br /><span style=\"background-color: #000000; color: #ffffff;\">onclick="saveCustomAttachment();return false"></span><br /><span style=\"background-color: #000000; color: #ffffff;\"><b>Please attach file</b></span><br /><span style=\"background-color: #000000; color: #ffffff;\"></button></span><br /><span style=\"background-color: #000000; color: #ffffff;\"><script></span><br /><span style=\"background-color: #000000; color: #ffffff;\">function saveCustomAttachment(){</span><br /><span style=\"background-color: #000000; color: #ffffff;\">var tableName = g_form.getTableName();</span><br /><span style=\"background-color: #000000; color: #ffffff;\">var sys_id_input = gel('sysparm_item_guid') ? gel('sysparm_item_guid').value : g_form.getUniqueValue();</span><br /><span style=\"background-color: #000000; color: #ffffff;\">if(tableName === "ni"){</span><br /><span style=\"background-color: #000000; color: #ffffff;\">saveCatAttachment(sys_id_input, 'sc_cart_item');</span><br /><span style=\"background-color: #000000; color: #ffffff;\">}else{</span><br /><span style=\"background-color: #000000; color: #ffffff;\">saveAttachment('sc_req_item', sys_id_input);</span><br /><span style=\"background-color: #000000; color: #ffffff;\">}</span><br /><span style=\"background-color: #000000; color: #ffffff;\">}</span><br /><span style=\"background-color: #000000; color: #ffffff;\"></script></span><br /><span style=\"background-color: #000000; color: #ffffff;\"></j:jelly></span></p>\r\n<p>5) Using this Add_Attachment_Var macro , create a new macro type catalog variable in the required catalog item.</p></section></div></article></div>"}</script>