Include attachment to Email notification on certain condition

Bchaudhary
Tera Contributor

Hey, 

 

Anyone know the alternative way of Include Attachment checkbox in Email notification. I am trying to create an email notification on incident record and want to send that notification with attachment on incident record on certain state of Incident.

11 REPLIES 11

Harish KM
Kilo Patron
Kilo Patron

Hi @Bchaudhary you can have the condition of state when to trigger Notification with attachment and without attachment. In this case you will have 2 notifications

Regards
Harish

Bchaudhary
Tera Contributor

@Harish KM Thanks for the response. I would only like to use one notification for all state. Any idea on that?

Hi @Bchaudhary in that case you need to create a email script with your condition inside email script to call this email script inside Notification

example:

you need to create email script with below script:

 

if(current.state == 3)

{

var gr = new GlideRecord('sys_attachment');


gr.addQuery('table_sys_id',current.sys_id);


gr.query();


if (gr.hasNext()) {


template.print("Attachments: <br />");


while (gr.next()) {


var attachLink = '<a href="' + gs.generateURL(gr.getTableName(),gr.sys_id) + '">' + gr.file_name + '</a>';


template.print(attachLink + "<br />");
}
template.print("<hr/>");
}
}

Regards
Harish

Hey @Harish KM, I tried it. But it seems working for users who have access to instance. What if external user wants to access it? Thanks