Carrying an attachment from one task to another in the same workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2012 07:46 AM
Is there a way to copy an attachment from one task to another in the same workflow? I saw this post: Copying attachments from an SC Item to the coressponding approval record for that item , but I'm hoping I can somehow use the scratchpad to do this. Is that possible? Any suggestions are greatly appreciated! Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2012 04:49 PM
Glad I could contribute something useful to the discussion!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2015 09:05 PM
This works great! I had to reconstruct the anchor tag but overall pretty slick!
Thanks,
Jeff

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2015 06:12 PM
Yeah, it looks like the community forum automatically converted the html tags that were included in the original reply.
In any event, I'm glad that solution is working for you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2013 12:15 PM
I've adapted this from a different script, so I apologize for any errors, but you should be able to include this in the "Advanced script" section of a Catalog Task activity within your workflow:
// Get all attachments.
var grAttachments = new GlideRecord('sys_attachment');
grAttachments.addQuery('table_sys_id', current.sys_id);
grAttachments.query();
var vAttachmentSys_id = '';
// Loop through all attachments.
while (grAttachments.next()) {
// Prep the primary attachment record.
grAttachments.table_name = 'sc_task';
grAttachments.table_sys_id = task.sys_id;
// Find all secondary attachment records.
var grAttachmentDocuments = new GlideRecord('sys_attachment_doc');
grAttachmentDocuments.addQuery('sys_attachment', grAttachments.sys_id);
grAttachmentDocuments.query();
// Duplicate the primary attachment record.
vAttachmentSys_id = grAttachments.insert();
// Loop through all secondary attachment records.
while (grAttachmentDocuments.next()) {
// Duplicate the current secondary attachment record.
grAttachmentDocuments.sys_attachment = vAttachmentSys_id;
grAttachmentDocuments.insert();
}
}
This script will copy the attachments of the parent requested item (assuming that your workflow runs against that record). If you want to pull the attachments from another catalog task or any other record, then you'll just need to find a way to get at the sys_id of the desired record, then use that value in this line:
grAttachments.addQuery('table_sys_id', current.sys_id);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2016 05:14 AM
GlideSysAttachment.copy('sys_attachment', '665e6f0a4fa31200c233eb118110c712', 'sys_data_source', 'd3fbec214f231200c233eb118110c7da');
Is it possible to copy attachment from attachment table to some other table?