The CreatorCon Call for Content is officially open! Get started here.

How do I identify who the notification event creator is?

Wayne Richmond1
Tera Contributor

I want technicians to be able to append email notifications with a personalised signature. I have created a field on the user form called 'Email signature' which they can update. I intend to write an email script that will be included in an email layout so that all notifications using the template\layout with pull in the user's signature. However, how do I identify is generating the email, i.e., who the event creator is? Is it the current user? If so, why doesn't this mail script work?

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {

    var user = gs.getUser();
    if (user.u_enable_email_signature == true) {
        template.print(user.u_email_signature);
    }


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

Thanks

1 ACCEPTED SOLUTION

Weird
Mega Sage

You can try
event.user_id

and

event.user_name

to get the user id and user name from the event. Then you can just use GR to get the information you want.

View solution in original post

4 REPLIES 4

Weird
Mega Sage

You can try
event.user_id

and

event.user_name

to get the user id and user name from the event. Then you can just use GR to get the information you want.

Basically you should be able to check any value that the event has in the sysevent table.

Thanks!

This is the code I used in the end:

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {

    var userGr = new GlideRecord('sys_user');
    userGr.get(event.user_id);
    if (userGr.u_enable_email_signature == true) {
        template.print(userGr.u_email_signature.replace(/\n/g, "<br>"));
    }

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

Saurav11
Kilo Patron
Kilo Patron

Please use the below:-

find_real_file.png

Please mark answer correct /helpful based on impact.