- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2024 01:39 PM
I would like to add an attachment to notification after the catalog task is closed. The notification is working but it is not capturing the attachment.
Note: The attachment field is one of the catalog variables, not the default attachment field
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2024 02:05 PM
I have figured it out. In workflow studio, i used 'Get variables' action to get the variable that has the attachment and use copy attachment action to copy it to the catalog task and finally used send notification action to send the attachment with the notification that i already created (I checked the 'include attachment' box in the notification). This works perfectly for me
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2024 09:22 PM
Hi,
You can try the GlideSysAttachment copy method.
This page has a lot of information about it:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2024 09:28 PM
Hi @DebbyDebby
Refer the below link.
Thanks
dgarad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2024 09:44 PM
Hi @DebbyDebby ,
Use below script to attach the attachment from catalog variable.
// Get the task's parent request item (RITM)
var ritmGR = new GlideRecord('sc_req_item');
if (ritmGR.get(current.request_item)) { // Assuming 'request_item' links the task to the RITM
// Query the sc_item_option_mtom table to fetch the attachment variable
var varMtomGR = new GlideRecord('sc_item_option_mtom');
varMtomGR.addQuery('request_item', ritmGR.sys_id);
varMtomGR.addQuery('sc_item_option.value', 'CONTAINS', 'sys_attachment'); // Ensure it's an attachment
varMtomGR.query();
while (varMtomGR.next()) {
// Get the sys_id of the attachment
var attachmentGR = new GlideRecord('sys_attachment');
attachmentGR.addQuery('table_sys_id', varMtomGR.sc_item_option.value); // Link the attachment to the RITM
attachmentGR.query();
while (attachmentGR.next()) {
// Attach the file to the notification
notification.addAttachment(attachmentGR);
}
}
}
-------------------------------------------------------------------------
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
12-13-2024 02:12 PM
It is an sc_task and it is created through a workflow so the attachment is from a specific sc_task generated for a workflow.