Copy attachment from sys_email table to RITM table.

karthikbabu
Giga Expert

Hi All,

 

I have a requirement. When user clicks a button on the RITM table it sends an email to the user and the user replies to the email with an attachment. Now I need to copy the attachment to the RITM table.

Any ideas...?

Thank you,

Karthik

1 ACCEPTED SOLUTION

amaradiswamy
Kilo Sage

Hi,

There is an OOTB inbound action already to update RITM if a user replies to the email sent by serviocenow (email should have watermark in body)

https://instance-name.service-now.com/sysevent_in_email_action.do?sys_id=1e33e31f0a0a3c74015b770ccb3...

include below script 

var sourceSysID = email.sys_id;

 

var targetSysID = current.sys_id;

 

var copyAtt = new GlideSysAttachment();

 

copyAtt.copy('sys_email',sourceSysID, 'sc_req_item',targetSysID);

View solution in original post

4 REPLIES 4

amaradiswamy
Kilo Sage

Hi,

There is an OOTB inbound action already to update RITM if a user replies to the email sent by serviocenow (email should have watermark in body)

https://instance-name.service-now.com/sysevent_in_email_action.do?sys_id=1e33e31f0a0a3c74015b770ccb3...

include below script 

var sourceSysID = email.sys_id;

 

var targetSysID = current.sys_id;

 

var copyAtt = new GlideSysAttachment();

 

copyAtt.copy('sys_email',sourceSysID, 'sc_req_item',targetSysID);

Thanks Amaradiswamy. I couldn't realized there is an OOB simple solution for this. Awesome.

AbhishekGardade
Giga Sage
Hello Karthick, ServiceNow Community Community 10+ Toggle navigation Copy attachment from one table to another - Developer Community Question Copy attachment from one table to another by sidarth created 3y ago (edited 3y ago ) in Developer Community Hi All, I have written a Business rule to copy attachment from sys_attachment to hr_case table when someone sends and attachment via the email client template on a hr record. (function executeRule(current, previous /*null when async*/) { // Add your code here var sys_id=current.sys_id; if(current.target_table=="hr_case"){ var gr= new GlideRecord('sys_attachment'); gr.addQuery("table_sys_id",sys_id); gr.query(); if(gr.next()){ GlideSysAttachment.copy('sys_attachment', gr.sys_id, current.target_table, current.instance); } } gs.info("completed"); })(current, previous); But it is not working. I cannot see any attachment on HR Case table. Also in the logs I see the following warning : "syslog_transaction not found for AjaxClientTiming: sysId: , table: , view: Default view, form: email_client_template" Any help would be appreciated Topics: Upvote (0) Reply (6) 2373 Views Accepted Solution See this answer in context Chuck Tomasi Forum Level 5 • 3y ago Hi Sidarth, The key to making this work is to find out what the real record is that the attachment is linked to. The attachment is IN sys_attachment, but it is not attached to a sys_attachment record. If you look in sys_attachment for that record, you will see the table name (see example image below.) THAT is going to be your source table and sys_id to use in the first arguments. The target table will be the current record's information (see 3rd and 4th args below.) GlideSysAttachment.copy(sourceTable, sourceSysId, current.getTableName(), current.sys_id); Thanks, Abhishek
Thank you,
Abhishek Gardade

AbhishekGardade
Giga Sage

Hello Karthick,

Check out the answer by Chuck.

https://community.servicenow.com/community?id=community_question&sys_id=93f183e9db98dbc01dcaf3231f96...


Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade

Thank you,
Abhishek Gardade