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 03:32 AM
Hi @Aryan ,
Write business rule on sc task table and Try below code.
(function executeRule(current, previous /*null when async*/) {
if (current.request_item) {
var ritmSysId= current.request_item.toString();
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', current.sys_id);
}
}
}
})(current, previous);
-------------------------------------------------------------------------
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:52 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2024 04:01 AM
Hi @Aryan ,
I have checked its working.
Do not change anything just paste the code it will work
Share your business rule screenshot if still not working.
-------------------------------------------------------------------------
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 04:16 AM
Hi @Runjay Patel ,
I am creating RITM and Sc_task via inbound email action, and in RITM the attachment is coming from the email. I just want to copy that attachment to sc_task.