Email Script to display change type in colour in Change Approval Request notification

Mi Mi
Tera Contributor

Hi

I need to update our current change approval request notification to display the change type in colour based on the type. For example,

Emergency = Red

Expedited = Orange

Normal = Blue

Is it possible to have just one email notification with an email script to achieve this? If so, could any of you please assist me in scripting.

Thank you in advance.

Regards

mmk

 

1 ACCEPTED SOLUTION

HI @Mi Mi type is a choice field, you can directly put the display value like below


    var gr = new GlideRecord("change_request");

    gr.addQuery("sys_id", current.sysapproval);

    gr.query();

    if (gr.next()) {
        if (gr.type == 'emergency')
            template.print('<p style="font-size:12px; color:red; font-family:arial">' + 'Emergency' + '<strong>');
        if (gr.type == 'normal')
            template.print('<p style="font-size:12px; color:orange; font-family:arial">' + 'Normal' + '<strong>');
        if (gr.type == 'expedited')
            template.print('<p style="font-size:12px; color:orange; font-family:arial">' + 'Expedited' + '<strong>');

    }
Regards
Harish

View solution in original post

5 REPLIES 5

Harish KM
Kilo Patron
Kilo Patron

HI @Mi Mi you can have a email script like below and call this email script in your Approval Notification:

change Type : ${mail_script:emailscriptname}

 

 var gr = new GlideRecord("change_request");

    gr.addQuery("sys_id", current.sysapproval);

    gr.query();

    if (gr.next()) {
        if (gr.type == 'emergency')
            template.print('<p style="font-size:12px; color:red; font-family:arial">' + gr.type + '<strong>');
        if (gr.type == 'normal')
            template.print('<p style="font-size:12px; color:orange; font-family:arial">' + gr.type + '<strong>');
        if (gr.type == 'expedited')
            template.print('<p style="font-size:12px; color:orange; font-family:arial">' + gr.type + '<strong>');

    }
 
HarishKM_0-1712207799282.png

 

 

Hint: you can play around in HTML editor and copy the source code and paste it in email script using template.print();

HarishKM_1-1712207919006.png

 

HarishKM_2-1712207943052.png

 

Regards
Harish

Mi Mi
Tera Contributor

Hi @Harish KM

Thank you for your prompt response. I will try it and get back to you.

Regards

mmk

Mi Mi
Tera Contributor

Hi @Harish KM

Thank you for sharing the script. The script works providing the change type variable name. I would like to have its display name. Would you be able to assist me how to modify your script?

Thank you in advance.

Regards

mmk

HI @Mi Mi type is a choice field, you can directly put the display value like below


    var gr = new GlideRecord("change_request");

    gr.addQuery("sys_id", current.sysapproval);

    gr.query();

    if (gr.next()) {
        if (gr.type == 'emergency')
            template.print('<p style="font-size:12px; color:red; font-family:arial">' + 'Emergency' + '<strong>');
        if (gr.type == 'normal')
            template.print('<p style="font-size:12px; color:orange; font-family:arial">' + 'Normal' + '<strong>');
        if (gr.type == 'expedited')
            template.print('<p style="font-size:12px; color:orange; font-family:arial">' + 'Expedited' + '<strong>');

    }
Regards
Harish