Add Attachment Button to Change Request Form

robertbc
Kilo Explorer

Hello all,

I'm trying to add a button on our Change Request form to enable users to attach files easily. I've searched around the forums and found a lot of answers pertaining to doing this on the Service Catalog or on the Record Producer... but nothing on Change (Adding attachment button to service catalog request)

I've searched around and found the following UI Macro (complete javascript/jelly novice):

<?xml version="1.0" encoding="utf-8" ?>

<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

<div align="center">

<button onclick="saveCatAttachment(gel('sysparm_item_guid').value, '$[item_table]')">Click here to add attachments <img src="images/icons/attachment.gif"></img></button>

</div>

</j:jelly>

I then referenced the Macro in a Formatter and added it to our Change Request form... however when I click the button, it throws an error notifying me about all the mandatory fields we have on the form. Then even if I fill in the form completely and hit the button, the page reloads

Ideally this is what I would like:

  1. The 'Attachments' button is in a formatter (or similar). Our Change Request form is lengthy so I need it to be on the actual form, not up at the top where the default paperclip attachment button is
  2. User clicks the button if they so choose (i.e NOT mandatory)
  3. They select and upload their attachment(s)
  4. *bonus* - there is some way to transfer the attachment to the task(s) that get generated when the request is submitted... or at least an easy way for the task 'executer' to access it

Any assistance is much appreciated. Thanks in advance!!

Robert

2 REPLIES 2

Mark Stanger
Giga Sage

Try this for your macro code...



<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">


      <button id="custom_add_attachment" type="button" onclick="saveAttachment(g_form.getTableName(), g_form.getUniqueValue());" class="icon-button icon-paperclip" title="Add attachments..."><b>Click here to add attachments...</b></button>


</j:jelly>


this is nice.