How to copy attachment from RITM TO sc_task in inbound email action?

Aryan
Tera Contributor

Hi All,

 

We have an inbound email action that is on RITM(sc_req_item) ,

 

1. So, when we send email to ABC@example.com with attachments.

2. The inbound email action will trigger and created a REQ, RITM & Sc_task record.

3. In RITM record it will attach all the attachment OOTB, but our requirement is to be attached those attachment in the sc_task record also.

 

Can anyone help me on this?

8 REPLIES 8

Hi Aryan,

 

I think you just need to add one more business rule to copy attachment from Requested Item to Catalog Task. Please refer to the link below it will help you with this case:

https://www.servicenow.com/community/now-platform-forum/copy-attachment-from-ritm-to-sc-task-on-requ...

Hi @Aryan ,

 

Creation of ritm and sc task do it from inbound and write business rule to copy the attachment.

If you want only for specific item then in when to run add the condition to check that item.

 

Or if you want to do it from inbound itself then use below code. run below code post RITM and SC task creation along.

var ritmSysId= get the sysid of ritm which you had created
      var taskSysId= get the sysid of sc task which you had created 
        var attachmentGR = new GlideRecord('sys_attachment');
        attachmentGR.addQuery('table_sys_id', ritmSysId);
        attachmentGR.query();
        var attachmentCount = attachmentGR.getRowCount();
     
        if (attachmentCount > 0) {
            while (attachmentGR.next()) {
                GlideSysAttachment.copy('sc_req_item', ritmSysId, 'sc_task', taskSysId);
            }
        }

 

 

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

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

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

Uncle Rob
Kilo Patron

Yes, but I'd be using Flow Designer instead of Inbound Email.  Once there its much easier to just drag and drop flow actions that do the work for you.  Here's a quick example I made.

UncleRob_0-1732621009676.png

- First thing it does is Look Up Records in sys_attachments where the table_name is the Table Name of the triggering RITM and table_sys_id is the Sys ID of the same triggering RITM.

- Then I do a For Each looping through the Look Up Records action I just defined.

- Then I use the OOB Copy Attachment action which asks for the source attachment and destination record.  It gets the source attachment from the iteration of the For Each you're in and the destination record is whatever action defined your Create SC_Task.

 

Here are some videos where you can learn more:
https://youtu.be/uLHCw2GA3lo

https://youtu.be/de1LnEPAVU0

Catalog Items are just a way to define inputs and launch flow. There are many reasons why the catalyst may be email. STEP BY STEP - Create the Catalog Flow as if you assumed form entry. - Create a new Flow Action to parse an email body for name:value pairs (OR download from share) - Create a ...

ersureshbe
Giga Sage
Giga Sage

Hi,

I hope below article will resolve your issue. Pls check,

https://www.servicenow.com/community/itsm-articles/code-lovers-attachment-integration-trick-amp-trea...

 

Regards,
Suresh.