how to add attachment in the workflow notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2024 09:03 PM
I have created a workflow and there is a notification in the workflow that is sending notification to the vendor that has no access to our servicenow instance.
In this notification we would like to include an attachment from the sc_req_item and how can I do that?
thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2024 09:17 PM
Hi @TMKAM ,
try with this code
(function execute(current, workflow) {
// current refers to the RITM (sc_req_item) in this case
// Fetch the first attachment for the current sc_req_item
var attachmentGR = new GlideRecord('sys_attachment');
attachmentGR.addQuery('table_name', 'sc_req_item'); // Look for attachments on sc_req_item
attachmentGR.addQuery('table_sys_id', current.sys_id); // Attachment for this specific record
attachmentGR.query();
while (attachmentGR.next()) {
// Associate the attachment with the notification by adding it to the event
gs.eventQueue(
'your.custom.notification.event', // The custom event linked to the notification
current, // Current record (RITM)
attachmentGR.sys_id.toString(), // Pass the attachment Sys ID
null // Any other parameters if needed
);
}
})(current, workflow);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2024 09:22 PM
Hi Tejas,
thank you for the script but im not sure where I should put it ? is in the notification or ???
thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2024 09:28 PM
Hi @TMKAM ,
click on advance checkbox it will one script . paste it here
first clear by default script and comments
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2024 09:31 PM - edited 12-04-2024 09:32 PM
Hi Tejas,
It is already advanced and i still need the default script and comment as i have circle in red color.