Need help with attachment carry-over from one RITM to another
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2024 11:38 AM
Hello all,
I have a request form that has attachment(s) that is/are required.
At some point, when the RITM closes it automatically opens a new RITM.
I have a requirement to copy any/all attachment(s) from the closed RITM into the new RITM.
Thank you

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2024 11:40 AM
@Hola Ola You should use,
copy(String sourceTable, String sourceID, String targetTable, String targetID)
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);
Please refer to this link for more information https://developer.servicenow.com/dev.do#!/reference/api/vancouver/server_legacy/GlideSysAttachmentGl...
Hope this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2024 11:42 AM
Hi,
As Sandeep highlighted you can use GlideSysAttachment.copy() however it will consume the storage size over the period of time by unncessarily duplicating the attachments.
Instead you can follow a relationship approach to get the attachments presented as Related list instead. Check link for directions.