How to get Notification name from sys_email table

Ap_1
Tera Contributor

Can anyone please suggest how to fetch notification name from sys_email table for a before insert business rule.

3 REPLIES 3

Sandeep Rajput
Tera Patron
Tera Patron

@Ap_1 Here is the script you should use inside your business rule.

(function executeRule(current, previous /*null when async*/ ) {

    // Add your code here
    var glideSysEmailLog = new GlideRecord('sys_email_log');
    glideSysEmailLog.addQuery('email', current.email);
    glideSysEmailLog.query();
    if (glideSysEmailLog.next()) {
        var notification_name = glideSysEmailLog.getDisplayValue('notification');
       gs.info(notification_name);
    }

})(current, previous);

Please mark the answer helpful and correct if it answers your question.

Hi Sandeep,

 

This is not working.

I have written a before BR, on sys_email table and if I GlideRecord on sys_email_log table for fetching the notification as below,

var glideSysEmailLog = new GlideRecord('sys_email_log');
    glideSysEmailLog.addQuery('email', current.email);

 it is showing no records, as may be at that time the log is not yet created on email logs, so not getting any record.

 

Thanks,

Aparajita

Jaspal Singh
Mega Patron
Mega Patron

Hi Aparajita,

You can find it in sys_email_log table.