Pradyumna Das
Tera Expert

To add all the attachments in the Email Client Template please follow the below procedure:

Create a Business Rule on the sys_email table with conditions before insert.

Script :

    var att = new GlideRecord('sys_attachment');
    att.addQuery('table_sys_id', current.instance);
    att.query();
    if (att.next()) {
        GlideSysAttachment.copy('<Record Table Name>', current.instance, 'sys_email', current.sys_id);
    }

/*Record Table Name- Source Table name. eg:- Suppose Email template is on the Incident table then we have to mention incident as the source table*/

Please the attached screenshot to know the output.

Please mark this article helpful if it helps you.  

 

Comments
Shruthisree H K
Mega Explorer

Thanks for the info.

Pradyumna Das
Tera Expert

@Rahul Raja Sami Have you written onBefore Insert BR !

Cinda Craig
Tera Expert

Hi Pradyumma,

 

I'm using your suggest on a scoped application but I'm finding the email client is attaching each attachment from the parent record twice.  Any suggestion as to why?

Pradyumna Das
Tera Expert

@Cinda Craig Could you please show me your code and also please check whether you have any other script running which will be copying any attachment or not?

James Piveta
Tera Contributor

Hi!

If you'd rather it work for any table, replace '<Record Table Name>' with current.target_table, instead of putting the table directly, like this:

 

GlideSysAttachment.copy(current.target_table, current.instance, 'sys_email', current.sys_id);

 

I suggest testing whether it works as expected in the workspace.

Version history
Last update:
‎07-27-2022 09:48 AM
Updated by: