- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2021 08:42 PM
How to copy attachment from sys_attachment table to a field of file attachment type in a custom table.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2021 01:05 AM
Hi,
then the same script can be used to update the attachment field
var att = new GlideRecord('sys_attachment');
att.addQuery('table_sys_id', current.sys_id);
att.query();
if(att.next()){
current.attachment_fieldName = att.sys_id;
current.setWorkflow(false);
current.update();
}
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
‎03-03-2021 08:50 PM
So, you want to set the attachment that is being displayed in an attachment type variable to be an attachment that already exists on the sys_attachment table?
Get the sys_id of the attachment you want and set the value of the field with g_form.setValue('field_name', 'sys_id');
I hope this helps!
If this was helpful or correct, please be kind and remember to click appropriately!
Michael Jones - Proud member of the CloudPires team!
Michael D. Jones
Proud member of the GlideFast Consulting Team!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2021 08:54 PM
Hi,
check these links and they should help you achieve with some enhancement
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
‎03-03-2021 09:31 PM
Hi Ankur,
I have created a BR for automatically attaching the pdf of the form to the record after submitting the record so that the approver can go through the pdf.Now I want to copy that attachment to the field in the form instead of showing the attachment at the top of the form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2021 11:41 PM
Hi Sarika,
update as this in the BR and set the attachment field name with the sys_id of the sys_attachment record
I assume this is before BR
var att = new GlideRecord('sys_attachment');
att.addQuery('table_sys_id', current.sys_id);
att.query();
if(att.next()){
current.attachment_fieldName = att.sys_id;
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader