Copy attachments from one SCTask to antoher

Kishor Mudhili
Giga Guru

hi Guys,

 

how we can copy attachments from one SC Tasks to another SCTasks.

 

for example: one request having multiple SCTasks, I 'm not going attach the attachments in Request.

I want to attach the attachment in any SCTAsk, that attachment should be copied to antoher tasks..

please help me. 

17 REPLIES 17

Sebastian L
Mega Sage
GlideSysAttachment.copy('sc_task', 'sys_id_of_source_record', 'sc_task', 'sys_id_of_target_record); //sourceTable, sourceID, targetTable, targetID

 

So the above uses the GlideSysAttachment (https://developer.servicenow.com/dev.do#!/reference/api/quebec/server/r_SGSA-copy_S_S_S_S

 

So I would implement this as part of the workflow that you are using, so you don't do it for ALL your sc_tasks. Could also potentially be on insert, but not sure that is the best approach, since you would need to look for any closed tasks, and then copy the attachments over - but there might be multiple. You could sort it by the latest etc, but I would do this as part of a Flow: https://docs.servicenow.com/bundle/tokyo-application-development/page/administer/flow-designer/refer...  (and then you can just use the Copy attachment action), or a workflow and you can do the above. 

OlaN
Tera Sage

Hi,

Can you please explain the use case for copying the attachments?

They can be made available by showing a related list, or other ways.

If you really are going through with this, there is also a no-code option, by creating a Flow that does the same as proposed business rules mentioned by others.

Example below.

 

flow-copy-attachment-from-task-to-task.png

elphilli
Tera Contributor

Hey OlaN,

 

Can you expand the Flow Designer for this? This has been asked to do for my organization.

 

Thanks,