How to fetch attachment from one table and populate that attachment to another table custom field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2023 02:30 AM
Hi All, I have a requirement to fetch the attachment from one table and stored/ autopopulate that attachment to custom field in servicenow. This custom field should autopopulate the attachment from table.
Thank you!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2023 02:35 AM
@s_105 What type of custom field you are referring here?
OOTB you can use GlideSysAttachment - copy(String sourceTable, String sourceID, String targetTable, String targetID)
Here is an example
var attachment = new GlideSysAttachment();
var incidentSysID = 'ab1b30031b04ec101363ff37dc4bcbfc';
var incGR = new GlideRecord('incident');
incGR.get(incidentSysID);
var copiedAttachments = attachment.copy('incident', incidentSysID, 'problem', incGR.getValue('problem_id'));
gs.info('Copied attachments: ' + copiedAttachments);
For more information, please refer to https://docs.servicenow.com/bundle/vancouver-api-reference/page/app-store/dev_portal/API_reference/G....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2023 02:38 AM
Hi @Sandeep Rajput ,
I am able to copy it at table level, but my requirement is to copy that attachment to field not to table.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2023 02:39 AM
@s_105 Could you please state your end goal here? Why would you like to copy the attachment at field level?