Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

Show attachment as link in Incident Resolution email notification

gauravsp
Giga Contributor

Is ServiceNow NOT allows to show incident attachment as a link in email notification.

 

Is yes, please provide short step or guidelines on this.

 

 

gauravsp_1-1789707192335.png

Highlighted text should show link to attachment.

2 REPLIES 2

pr8172510
Kilo Sage

Hi @gauravsp ,

Yes, ServiceNow allows you to show an Incident attachment as a clickable link in an email notification.

I tested this approach in my instance using a Notification Email Script that queries the sys_attachment table for attachments belonging to the current Incident and generates a clickable attachment URL.

Notification Email Script:

(function runMailScript(current, template, email, email_action, event) {

    var attachment = new GlideRecord('sys_attachment');

    attachment.addQuery('table_name', current.getTableName());
    attachment.addQuery('table_sys_id', current.getUniqueValue());
    attachment.query();

    while (attachment.next()) {

        var attachmentUrl =
            gs.getProperty('glide.servlet.uri') +
            'sys_attachment.do?sys_id=' +
            attachment.getUniqueValue();

        template.print(
            '<div style="margin-top:5px;">' +
            '<strong>Attachment:</strong> ' +
            '<a href="' + attachmentUrl + '">' +
            attachment.getValue('file_name') +
            '</a>' +
            '</div>'
        );
    }

})(current, template, email, email_action, event);


Notification
:

Hello ${caller_id.first_name},

Your incident has been solved.

${number}

Solution notes:
${close_notes}

${mail_script:Show Incident Attachment Links}

It will be automatically closed in 5 business days.

If the solution does not resolve your issue, you may reopen the incident.

Thank you,
Helpdesk



steps:

  1. Create a Notification Email Script.
  2. Call the Mail Script from the notification using:

    ${mail_script:Show Incident Attachment Links}
  3. Keep Include attachments unchecked if you only want the clickable link rather than the file attached to the email.

    pr8172510_0-1789721129941.pngpr8172510_1-1789721159468.pngpr8172510_2-1789721191906.png

     

 

Ankur Bawiskar
Tera Patron

@gauravsp 

if the notification doesn't have that, you can include your custom logic and links using Email script

what did you start with and where are you stuck?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader