Copy attachment to Approval

Mike_R
Kilo Patron
Kilo Patron

In one of our workflows, we have a task and then an approval. I need help copying the attachment from the task to the approval so the attachment gets included in the approval email. Can anyone help me with the script?

1 ACCEPTED SOLUTION

mike275
Mega Expert

It's pretty easy to copy an attachment, you just need the original attachment's table name ('sys_task' in your case) and the sys id for the task (these are the first 2 arguments below). 

Then, the next 2 arguments are the table name and sys_id for the record you want to copy to:

 

new GlideSysAttachment().copy(originalAttachment.table_name, originalAttachment.table_sys_id, destinationTableName, destinationSysId);

View solution in original post

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Mike,

Is the email notification on task table or approval table?

There is an option to include attachments in the email notification settings.

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Approval is on the approval table.

mike275
Mega Expert

It's pretty easy to copy an attachment, you just need the original attachment's table name ('sys_task' in your case) and the sys id for the task (these are the first 2 arguments below). 

Then, the next 2 arguments are the table name and sys_id for the record you want to copy to:

 

new GlideSysAttachment().copy(originalAttachment.table_name, originalAttachment.table_sys_id, destinationTableName, destinationSysId);

Would I add this to the approval activity in the workflow? I guess where I'm struggling is that the attachment would need to be copied before the approval email is sent.