Jon Ulrich
Kilo Guru

Implement this after Update business rule on your Email Script [sys_script_email] table to update any references to your email notification script when the name is changed

find_real_file.png

    var notifications = new GlideRecord('sysevent_email_action');
    notifications.addEncodedQuery('message_htmlLIKE${mail_script:' + previous.name);
    notifications.query();
	var count=0;
    while (notifications.next()) {
        var body = notifications.message_html;
        reg = new RegExp('\\$\\{mail_script:' + previous.name + '\\}', 'gmi');
        body = body.replace(reg, '${mail_script:' + current.name + '}');
        notifications.message_html = body;
        if(notifications.update())
			count++;
    }
    gs.addInfoMessage(count +" notifications updated with new email script reference");
Version history
Last update:
‎12-21-2020 11:46 AM
Updated by: