Is there a way to set an email as High Importance using a Mail Script?

neil_b
Tera Guru

I have one notification that gets triggered to be sent several weeks before the due date, and every subsequent week after that until the due date. 

 

There is a requirement for the fourth notification that is sent exactly the last week before the due date, to have the email sent as High Importance. 

 

Is there a way to accomplish this using a mail script? I am trying to avoid creating a second duplicate notification just to handle High Importance and would prefer to simplify things and have it handled conditionally in a mail script. 

 

This is what my mail script is now but it's not working. I think it's not working because my notification is triggered from the cmn_location table and so using current.email.importance isn't valid syntax. I'm not sure how to glide into the notification itself. 

    var gdt = new GlideDateTime().getMonthUTC();
    var today = new Date();
    var month = gdt;
    var dayOfMonth = today.getDate();
    var reminder = '';
    if (month == 1 && dayOfMonth == 1) {
        reminder = 'first';
    } else if (month == 1 && dayOfMonth == 7) {
        reminder = 'second';
    } else if (month == 1 && dayOfMonth == 15) {
        reminder = 'third';
    } else if (month == 1 && dayOfMonth == 22) {
        reminder = 'fourth';
    }

    if (reminder == 'fourth') {
        current.email.importance = 'high';
    }

 

1 ACCEPTED SOLUTION

@neil_b

then have separate notification for 4th iteration and set the Importance=High at notification level

Have a separate event for 4th iteration and link it with above email

In your script when it's 4th iteration, use this event so that the high importance notification is sent

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

@neil_b 

try setting the Importance to High at notification level

AnkurBawiskar_0-1747139737046.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

@Ankur Bawiskar I need to do it conditionally, using a mail script if possible. If I set it to High at the notification level, then every notification will be sent with High Importance. I only need the 4th iteration of the same notification being sent to be sent with High Importance.

@neil_b

then have separate notification for 4th iteration and set the Importance=High at notification level

Have a separate event for 4th iteration and link it with above email

In your script when it's 4th iteration, use this event so that the high importance notification is sent

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

@neil_b 

another way is if you have some unique email subject for 4th iteration then you can use before insert BR on sys_email and set the importance field

if(current.subject.indexOf('unique subject for 4th iteration') > -1)
current.importance = 'high';

If my response helped please mark it correct and close the thread so that it benefits future readers.

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