Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Inbound action do not copy attachment to csm record

Zuri
Tera Expert

I need help on script when inbound email received is posted to record but the attachment is not uploaded.

3 REPLIES 3

Runjay Patel
Giga Sage

Hi @Zuri ,

 

You can use below script to do so, just make some changes, like replace your target table and column details.

 

 

var sysAttach = new GlideSysAttachment();   
var emailSysId = sys_email.getUniqueValue(); 
if (emailSysId) { 
   var sysEmailAttachments = sysAttach.getAttachments("sys_email", emailSysId); 

   while (sysEmailAttachments.next()) { 

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

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

         sysEmailAttachments.update(); 

   } 


} 

 

 

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

The attachment is copied in the activity log but is not showing on top of the record.

Bhavya11
Kilo Patron
Kilo Patron

Hi @Zuri ,

 

You should use below logic in your inbound action to copy the attachments from sys_email table to your table.

syntax:

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

example:

GlideSysAttachment.copy('sys_email', sys_email.sys_id, 'incident', incident.sys_id);

 

 

Refer this for more detailed 

 

Please mark answer helpful/correct.

Thanks,

BK