How Do I Set the Importance of an Email in Flow Designer?

cwolfe01
Giga Guru

I have an action that I'm using as part of a flow to send an email to a user containing a list of all open incidents in their name. I would like to be able to set the importance of the email to "High" within the script, but am unsure how to do this. Could anyone advise?

 

The Script step of my action has an input variable called grIncident whose value comes from a Look Up Records step with certain conditions applied. Here's the script I'm using:

 

(function execute(inputs, outputs) {

    var tableStyle = '<td style="border:1px solid black;border-top-color:gray;border-left-color:gray;text-align:left;vertical-align:top">';

    var start = '<table style="border:1px solid black;border-top-color:gray;border-left-color:gray;"><tr><th style="border:1px solid black;border-top-color:gray;border-left-color:gray;text-align:left;vertical-align:top">Number</th><th style="border:1px solid black;border-top-color:gray;border-left-color:gray;text-align:left;vertical-align:top">Priority</th><th style="border:1px solid black;border-top-color:gray;border-left-color:gray;text-align:left;vertical-align:top">State</th></tr>';

    var data = '';

    var end = '</table>';

    while (inputs.grIncident.next()) {
        data += '<tr>';
        data += tableStyle + inputs.grIncident.number + '</td>';
        data += tableStyle + inputs.grIncident.priority + '</td>';
        data += tableStyle + inputs.grIncident.state.getDisplayValue() + '</td>';
        data += '</tr>';
    }

    outputs.emailbodyoutput = start + data + end;

    outputs.emailbodyout.setHeader("Importance", "high");


})(inputs, outputs);
1 ACCEPTED SOLUTION

Sandeep Rajput
Tera Patron
Tera Patron

@cwolfe01 A lot of folks tried searching for the similar solution to set the importance flag via scripting. Unfortunately, nothing worked be it email.setHeader('Importance','high'); or email.imporance='high'; 

 

On this thread https://www.servicenow.com/community/developer-forum/in-the-email-client-how-can-i-let-the-user-set-... a user suggested to create a business rule on sys_email table, add a condition in the BR to filter the email with a specific subject line and the in the script set the importance using current.importance='high';

 

This seems to be the only solution which has worked for the users so far.

 

Hope this helps.

View solution in original post

3 REPLIES 3

Hemanth M1
Giga Sage
Giga Sage

Hi @cwolfe01 ,

 

i don't think you can set the importance here however,

why don't you configure a notification(have the same logic) and call that notification either using gs,eventQueue in the flow or using Send notification action , set the importance in the notification as below.

 

HemanthM1_0-1698502936596.png

 

 

 

 

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

Sandeep Rajput
Tera Patron
Tera Patron

@cwolfe01 A lot of folks tried searching for the similar solution to set the importance flag via scripting. Unfortunately, nothing worked be it email.setHeader('Importance','high'); or email.imporance='high'; 

 

On this thread https://www.servicenow.com/community/developer-forum/in-the-email-client-how-can-i-let-the-user-set-... a user suggested to create a business rule on sys_email table, add a condition in the BR to filter the email with a specific subject line and the in the script set the importance using current.importance='high';

 

This seems to be the only solution which has worked for the users so far.

 

Hope this helps.

Raghu Ram Y
Kilo Sage

Hi @cwolfe01,

I would suggest you to call notification instead of triggering it through script, however if you want goahead from flow itself then use GlideEmailOutbound()  and use the below line for setting the priority, I hope it helps, please give a try and let me know whether it works.

email.addMailTo("X-Priority", "2"); 

Please mark my response as both HELPFUL and CORRECT, if it helps.

Regards.

Raghu.