How to add attachments from email to attachments on record?

Charlie Ward
Kilo Expert

When I need to communicate with an end user and send them an attachment from within a record, I use the Email icon on the toolbar. This opens up a standard "New Email" window. I fill in the To, From, Subject and body. I then add an attachment and then click send. However, after the email is sent, the record does not get updated with the attachment. How do I do this without having to manually add the attachment before or after I send the email?

1 ACCEPTED SOLUTION

srinivasthelu
Tera Guru

Hi Charlie,



I would   create a oninsert Business Rule on sys_email   table and look for emails that going out with the header something like this "X-ServiceNow-Source: EmailClient"



and copy attachments



Name: Copy Attachments from Record to Record


Type:


Table:


Description:


Parameters:


Script:



GlideSysAttachment.copy('sourcetable', 'sys_id', 'destinationtable', 'sys_id');


Note


Note: GlideSysAttachment.copy copies all attachments; it cannot select specific attachments.

Thanks


Srini



Mark this response as helpful/correct if does so.


View solution in original post

3 REPLIES 3

srinivasthelu
Tera Guru

Hi Charlie,



I would   create a oninsert Business Rule on sys_email   table and look for emails that going out with the header something like this "X-ServiceNow-Source: EmailClient"



and copy attachments



Name: Copy Attachments from Record to Record


Type:


Table:


Description:


Parameters:


Script:



GlideSysAttachment.copy('sourcetable', 'sys_id', 'destinationtable', 'sys_id');


Note


Note: GlideSysAttachment.copy copies all attachments; it cannot select specific attachments.

Thanks


Srini



Mark this response as helpful/correct if does so.


Do you have an example I could follow? I'm still new to the coding thing and I'm the only developer/sys admin for my whole company. We have a table called Facilities Request (facilities_request) and we use the Requested Item table (sc_req_item) also. I'm needing any emails sent out or any incoming emails with attachments to be added to the existing record on the facilities request or requested item table.


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Charlie,



Srinvas is right. You have to use GlideSysAttachment to copy the record to the target "incident" table. Please refer the sample example and adjust your code accordingly.


http://wiki.servicenow.com/index.php?title=Copy_Attachments_from_Record_to_Record