PrashantLearnIT
Giga Sage

I have explained how to Copy Attachments from one table to another using Business Rules.

If you have any feedback related to the scripting part, please write it in the comment box.

====================BUSINESS RULES======================

Table - Requested Item
When to Run - Before Update
Condition - Send Attachments to True
Scripts - 
(function executeRule(current, previous /*null when async*/ ) {

    // Add your code here
    var copy = new GlideRecord('problem');
    copy.addQuery('parent', current.getUniqueValue());
    copy.query();
    if (copy.next()) {
        GlideSysAttachment.copy('incident', current.getUniqueValue(), 'problem', copy.getUniqueValue());
    }
})(current, previous);

 

Best Regards,

Prashant

If my article helped you in any way, please mark this as helpful and make this a bookmark.

Comments
Maneesh T
Tera Explorer

very useful content

Amol Pawar
Tera Guru

Hi @PrashantLearnIT ,

 

Does the above script copy all the attachments at once?

What if I want to copy the attachment added via the record producer variable from the 'sys_attachment' table to any custom table?

 

Thanks,

Amol

PrashantLearnIT
Giga Sage

Hi Amol,

 

It is copying one for now.

santosh_k
Tera Contributor

Hi Prasant , thank for this great article.

 

However if  I may ask , if it is possible to copy an email from one table to another.

For example . an reply email was sent to an interaction and a case is being created from the email (Via flow)and the new case should have the Inbound reply email  in the email related list. 

 

Thanks in advance for your reply.

mohamadalha
Tera Contributor

I’ve implemented the same functionality using Flow Designer, which moves uploaded attachments between the Case and Incident tables one by one. This approach allows me to control the process and avoid duplicate attachments

Copy Attachments flow.png

Version history
Last update:
‎08-05-2022 07:55 AM
Updated by: