How to copy the attachments via Inbound email action into Servicenow Incident table?

Tj14
Tera Contributor

I have a scenario where the attachments on the Incident table should be sent over to the third party via email notifications and I was able to achieve it via email_script.

The main challenge is that if they send an attachment via email to servicenow, how do we copy that attachment into servicenow and associate with its incident opened here. We have an inbound email action defined to read the body of emaiil and reading the data.

1 ACCEPTED SOLUTION

Deepak Ingale1
Mega Sage

It should happen automatically by default.

If not, you can perform current.update() in inbound email actiion.

 

If it still not work, please feel free to use GlideSysAttachment() API using copy() method

 

Note: Please mark reply as correct / helpful if it answers your question

View solution in original post

16 REPLIES 16

Should happen automatically.
Do you have an inbound action that you know is generating Incidents but NOT attaching attachments?

 

Tj14
Tera Contributor

I am not using the OOB, I have a separate inbound action created. Where I am just using it to read the body of the email and create an incident with mapping all fields coming from XYZ to the incident fields in SNOW. I have nothing in particular to read the attachments in my script.

Should still happen automatically.

Tj14
Tera Contributor

I will be receiving the attachments from XYZ in the email in this format attached below. And we have to process that on our side

Rohit Kaintura
Mega Guru

Use this:

 

var sysAttach = new GlideSysAttachment();   


var emailSysId = sys_email.getUniqueValue(); 


gs.log("Email sys_id is: " + emailSysId, "TITUS");



if (emailSysId) { 


   var sysEmailAttachments = sysAttach.getAttachments("sys_email", emailSysId); 


   gs.log("Number of attachments found: " + sysEmailAttachments.getRowCount(), "TITUS");


   gs.log("Updating attachments to table: " + current.getTableName() + " and sys_id: " + current.getUniqueValue(), "TITUS");



   while (sysEmailAttachments.next()) { 


         sysEmailAttachments.setValue("table_name", current.getTableName()); 


         sysEmailAttachments.setValue("table_sys_id", current.getUniqueValue()); 


         sysEmailAttachments.update(); 


   } 


}