How to copy attachment from RITM TO sc_task in inbound email action?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2024 03:08 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2024 05:06 AM
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:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2024 05:47 AM
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
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2024 03:40 AM
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.
- 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2024 04:26 AM
Hi,
I hope below article will resolve your issue. Pls check,
Suresh.