how to add attachment in the workflow notification

TMKAM
Tera Contributor

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

 

TMKAM_2-1733374951780.png

 

TMKAM_0-1733374827709.pngTMKAM_1-1733374888097.png

 

5 REPLIES 5

Community Alums
Not applicable

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);

Hi Tejas,

thank you for the script but im not sure where I should put it ? is in the notification or ???

thank you

Community Alums
Not applicable

Hi @TMKAM ,

click on advance checkbox  it will one script . paste it here

Tejas_18_0-1733376453627.png

first clear by default script and comments

 

Hi Tejas,

It is already advanced and i still need the default script and comment as i have circle in red color.

TMKAM_0-1733376696196.png