- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2022 08:36 AM
Want Attachment Type field on manage attachment screen. i want to save this selected attachment type in sys_attachment table against uploaded document . how it is possible ?
for refrence adding the image below
Solved! Go to Solution.
- Labels:
-
Multiple Versions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2022 12:44 PM
Note: The Solution presented here is for Quebec, i've noticed that at least the line numbers are different on San Diego (where i have *not* tested this solution yet).
The Screenshot you have posted shows a modification to the OOTB attachment UI Page: /nav_to.do?uri=sys_ui_page.do?sys_id=b1b390890a0a0b1e00f6ae8a31ee2697
What you have to do is the following (all Global Scope):
- Add a new Choice Field to the sys_attachment table
- Create a Client Side Script Include that will write the attachment type after upload (i couldn't think of a better solution right now)
var AttachmentTypeHelper = Class.create(); AttachmentTypeHelper.prototype = Object.extendsObject(AbstractAjaxProcessor, { // just the snippet setAttachmentType: function () { var attachmentType = this.getParameter('attachment_type'); var attachmentGr = new GlideRecord('sys_attachment'); if (attachmentType && attachmentGr.get(this.getParameter('attachment'))) { attachmentGr.u_attachment_type = attachmentType; attachmentGr.update(); return true; } return false; }, type: 'AttachmentTypeHelper' });
- Modify the attachment UI Page HTML:
Script to Copy & Paste:
<tr> <td colspan="3"> ${new GlideRecord('sys_attachment').getElement('u_attachment_type').getLabel()}:$[SP]<g:ui_choicelist name="attachment_type" table="sys_attachment" field="u_attachment_type" /> </td> </tr>
- Modify the attachment UI Page Client Script:
Code Snippet for Copy & Paste:
var ga = new GlideAjax('AttachmentTypeHelper'); ga.addParam('sysparm_name', 'setAttachmentType'); ga.addParam('attachment', id); ga.addParam('attachment_type', $('attachment_type').value); ga.getXMLAnswer(function(){});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2022 08:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2022 08:31 PM
Hi,
It's not recommended to customize OOB UI page
But if you still require then steps are mentioned below
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2022 12:44 PM
Note: The Solution presented here is for Quebec, i've noticed that at least the line numbers are different on San Diego (where i have *not* tested this solution yet).
The Screenshot you have posted shows a modification to the OOTB attachment UI Page: /nav_to.do?uri=sys_ui_page.do?sys_id=b1b390890a0a0b1e00f6ae8a31ee2697
What you have to do is the following (all Global Scope):
- Add a new Choice Field to the sys_attachment table
- Create a Client Side Script Include that will write the attachment type after upload (i couldn't think of a better solution right now)
var AttachmentTypeHelper = Class.create(); AttachmentTypeHelper.prototype = Object.extendsObject(AbstractAjaxProcessor, { // just the snippet setAttachmentType: function () { var attachmentType = this.getParameter('attachment_type'); var attachmentGr = new GlideRecord('sys_attachment'); if (attachmentType && attachmentGr.get(this.getParameter('attachment'))) { attachmentGr.u_attachment_type = attachmentType; attachmentGr.update(); return true; } return false; }, type: 'AttachmentTypeHelper' });
- Modify the attachment UI Page HTML:
Script to Copy & Paste:
<tr> <td colspan="3"> ${new GlideRecord('sys_attachment').getElement('u_attachment_type').getLabel()}:$[SP]<g:ui_choicelist name="attachment_type" table="sys_attachment" field="u_attachment_type" /> </td> </tr>
- Modify the attachment UI Page Client Script:
Code Snippet for Copy & Paste:
var ga = new GlideAjax('AttachmentTypeHelper'); ga.addParam('sysparm_name', 'setAttachmentType'); ga.addParam('attachment', id); ga.addParam('attachment_type', $('attachment_type').value); ga.getXMLAnswer(function(){});