Add attachments to the email function from the existing incident record.

Khalnayak
Tera Guru

Hi,

I have a requirement to allow users to add attachments from the existing incident record when using the email function.

I have come across articles, which leverage before BR and attaches all the attachments to the email.

I do not want that, In the email when i click on the attachment icon, I should see all the attachments from the incident there.

Also I have seen BR scripts which duplicate the attachment when sent.

Please help.

1 ACCEPTED SOLUTION

can you try with below code. 

 

After "Insert" business rule on "sys_email" table .

 

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);

 

See if its not creating duplicate attachment on email client. 

View solution in original post

20 REPLIES 20

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

If you wish to send files added as attachment via email notification then you need to use Include Attachment checkbox on notificataion

Regards
Ankur

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

Hi Ankur, I dont want notifications always attached, when sending emails, only when the attachment icon in the email window is clicked, then they should be able to be selected from there.

Hope that makes sense.

Hi,

So are you saying when user clicks the Email client icon the attachments from the existing record should be seen there automatically?

Are you saying you want attachments to be copied to that form?

refer this article for help

Copy attachments to Email Client Template (...)

Regards
Ankur

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

Hi Ankur, yes that's what I want.

I have already followed the article you have mentioned but that attaches the attachment to the email, rather than me clicking on the attachment icon and selecting.

It also duplicates the attachments if i have 2 or more attachments.

So this is not a viable solution.

Can you advise a revised BR of that which I can use to meet my requirements please?

 

Before insert/update BR being used from the article is:

(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);