Custom Attachment Button and Use it anywhere in the form as Attachment Formatter
Custom Attachment button and use it anywhere in the form Using UI Macro and Formatter
Create a UI Macro for an Attachment:
- Navigate to System UI> UI Macros.
- Click New.
- Complete the form.(name it as add_attachment)
- In the XMLscript field enter below Script:
<?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 type="button" onclick="saveAttachment(g_form.getTableName(), g_form.getUniqueValue())">Attachment</button>
</j:jelly>
Refer below SS:
Create a Formatter :
- Navigate to System UI> Formatters.
- Click New.
- In the Namefield, enter a descriptive name for the formatter.(In our case name would be Attachment on Form)
- In the Formatterfield, enter the name of the UI macro with .xml appended to it. (In our case UI Macro name would be add_attachment)
- In the Table field, select the table in which the formatter will be used.
- In the Type field, select Formatter.
- Click Submit.
Refer below SS:
Yes we are done here , now lets open an Incident form layout and add our Attachment on Form formatter in a form and save it as shown below:
Now in an Incident form you will see the Attachment button as shown below:
When you will click on it , you will be having an ability to attach a file:
I am open for suggestions and improvement so feel free to comment on the article.
That’s all guys, if you find this article helpful please like, share and Subscribe!!
See you
Ajay
+91-9769949577
Labels:
https://www.servicenow.com/community/now-platform-articles/custom-attachment-button-and-use-it-anywhere-in-the-form-as/ta-p/2309585
