Carrying an attachment from one task to another in the same workflow

Blair5
Tera Guru

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.

14 REPLIES 14

tony_fugere
Mega Guru

I'm having a difficult time dissecting your requirement here to understand why you may want to use the


workflow.scratchpad
. The Packages.com.glide.ui.SysAttachment.copy method should provide everything you need to copy attachments from one task to another.

Just use a Run Script activity to go pull your two task records and copy attachments.


Packages.com.glide.ui.SysAttachment.copy('sourcetable', 'sys_id', 'destinationtable', 'sys_id');


Blair5
Tera Guru

Tony,

Thanks for the feedback. What you're suggesting is what I'm looking for.

I'm just not sure what goes where within this script. The workflow is on the sc_req_item table and the tasks are on the sc_task table, so do I have the first part set up right? (See below) Where do I get the sys_ids?

Packages.com.glide.ui.SysAttachment.copy('sc_req_item', 'sys_id', 'sc_task', 'sys_id');




The RITM is simple,


current.sys_id
, but the task is more difficult. Depends on when the activity occurs in the workflow. You may have to run a GlideRecord query to go fetch the catalog task(s) to which you want to copy the attachments.

Is this better suited to be a business rule to always copy attachments from sc_req_item to sc_task?

If so, it would look like:

Name: Copy request item attachments
Table: sc_task
When: Async
Insert: true
Script:

Packages.com.glide.ui.SysAttachment.copy('sc_req_item', current.request_item.sys_id, 'sc_task', current.sys_id);


Hi Tony,

It's been over a year since I originally posted this question. The issue has come up again and I need to copy an attachment from an item to a task. I tried your script, but it didn't work. I also trying querying the item table for the associated tasks, but that didn't work. I'm using Berlin 5 Hotfix 2.