
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 05-04-2020 08:35 AM
For those who are frequent users of Email Client Template have you come across a scenario where you need to send the same attachments from incident/change or any table where you have Email Client template enabled on?
If so, I guess the approach being used would be download the attachments first & then get it attached to the Email Client. It may time consuming as it requires unncessary downlad first & then attach again. To remove the redundant step of download & then attach we can have an option where we can copy the attachments directly to Email Client template from the record.
Consider an example of Incident where you have 5 documents attached & all of these 5 needs to be sent you can have an option of 'Include Attachments' from Notification but you may not want the attachments to sent always & thus is not the option you may opt for.
In that case you just get a Before Insert/Update Business rule on Email (sys_email) table with below snippet & its done.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var lookforatt=new GlideRecord('sys_attachment');
lookforatt.addQuery('table_sys_id',current.instance);
lookforatt.query();
while(lookforatt.next())
{
GlideSysAttachment.copy('incident', current.instance, 'sys_email', current.sys_id);
}
})(current, previous);
What the above code does is just copies all the attachment from source (incident) in above case to Email Client. Something like below.
For instance a record has 3 attachments.
When Email Client Template is opened all attachments are copied.
GlideSysAttachment.copy('incident', current.instance, 'sys_email', current.sys_id);
where 'incident' is source table & can be replaced with required table for copying the attachment from record to Email Client template.
Thanks,
Jaspal Singh
- 9,706 Views

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Jaspal,
How you get view option for attachment on email client. Could you plaese let me know.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Jaspal, i've followed your steps (very helpful article!) but the attachments are duplicating, sometimes tripling in the client, have you experienced this?

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
If you closely see it simply copies attachment from record where the mail client is used. Can you check if there are some additional business rule running on the Email (sys_email) table.

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
try with below script.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
GlideSysAttachment.copy(current.target_table, current.instance ,'sys_email', current.sys_id);
})(current, previous);
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Can you paste the script which you have used ? if you see my above response and the script which I have mentioned, that will absolutely not going to create any duplicate attachment.
Note: Working perfectly on Paris patch 3 as well .
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi
Thank you for taking the time to answer though, it's appreciated!
//Rashid
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi all,
We had this solution also running in our instance but it gave us problems with the OOTB functionality on notifications "Include attachments". It overrides the functionality.
I have changed the condition to query and it works great now.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
could you please tell what does current.instance will do? to get the sys id of the incident record whether current.getTabelName or current.sys_id will not work?
Thanks again.

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Thanks,
Snehaja
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var lookforatt=new GlideRecord('sys_attachment');
lookforatt.addQuery('table_sys_id',current.instance);
lookforatt.query();
while(lookforatt.next())
{
GlideSysAttachment.copy('sn_customerservice_case', current.instance, 'sys_email', current.sys_id);
}
})(current, previous);
Issue1: Every attachment added are duplicating on Email Client
Issue2: Emails sent are also having duplicate emails.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi people,
to resolve issue with duplicite entries, you have to set limit 1 to the query, it is because function:
GlideSysAttachment.copy('sn_customerservice_case', current.instance, 'sys_email', current.sys_id);
}
do always copy all attachments from a record so if you run it as many times as many attachments you have in the record you are creating duplicates.
Just change a function something like this:
I hope this will be helpful.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi people,
to resolve issue with duplicite entries, you have to set limit 1 to the query, it is because function:
GlideSysAttachment.copy('sn_customerservice_case', current.instance, 'sys_email', current.sys_id);
}
do always copy all attachments from a record so if you run it as many times as many attachments you have in the record you are creating duplicates.
Just change a function something like this:
I hope this will be helpful.

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
This was helpful, and I think you also need to make the Business Rule "After Insert" only, not after Update.
To address Issue #2, I did the following:
The SetLimit(1) function prevents duplicates to show up in the Email Client popup, and the Business Rule "After Insert" only prevents it from firing again after you hit "Send", which updates sys_email and changes the email Type field to "send-ready". This would trigger the BR again.
I guess you can also prevent this from happening by setting a condition on the BR to check for this value.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
All,
I've submitted an Idea on the Idea Portal to have this added as a feature, please review and consider lending your support.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
I have similar requirement, I want to copy CC users and email history to the email client. Is that possible? Please suggest

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
By CC users you mean watchlist users? Did you try configuring something if so share for a check.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Fair warning, don't make this a "While" loop, replace with IF.
Otherwise it will exponentially increate the number of emails, as the "GlideAttachment.copy" function already handles ALL record attachments. no need to iterate through all related attachments.
I also strongly recommend having strict conditions on this BR to only run for outbound emails composed from the email client.
@Jaspal Singh please edit the post if possible. So people don't use the original posted script
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
I know it's been a while since this had any replies, but I'm curious as to how you can modify this to pull from the Email Template itself. So if we put an attachment on the Quick Message template, how do you pull that attachment into the Email client automatically?
It's really silly that this hasn't been addressed OOTB already. If your template includes attachments, you would think it would automatically pull them in.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
@Jaspal Singh I realize this post is from awhile ago, but my client has a need for this to be implemented, but our hang up is that one of our assignment groups does not want this functionality for their team when they are using the email client.
Is there a way to make this feature not 'global' or to make it so this specific assignment group is excluded by using category? We've tried altering the script, but it doesn't seem to be working. Any help would be amazing! I have provided our script below:
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi,
The above BR attaches helps. But the problem is when attachments are added not only to Forward function, but also while using Reply and Reply All. In Reply and Reply All the attachment should not be added. Please help
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
If you'd like to only copy attachments when using the Email Client and not the automatic email notifications then you can add a condition to filter where 'header' contains 'X-ServiceNow-Source: EmailClient'. Otherwise attachments will be copied to all outgoing email from the ticket. Not sure about previous releases but we're on Washington.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
@Harsha Vardhan your script is working as suggested in the classic interface, but in the CSM/FSM configurable workspace we have the option to select from the record or computer and attach the required attachments. So when this business rule stays active. In the workspace, while sending emails to the end user, it sends all the attachments irrespective of whether any attachments are selected or not. Please help me to resolve this issue.