Add to Email notifications

JVINAY
Tera Contributor

Hi Team, 

My requirement is:

add to email notifications: 
Is this CIR associated with any migration factory or other enterprise tracking initiatives?
If answer is Yes to the following question(s), display:  MF2

Is this in scope of MF2 initiative? = Yes.

 

How can I achieve these, please help to achieve this requirement.

6 REPLIES 6

Viraj Hudlikar
Giga Sage

Hello @JVINAY 

No, this cannot be achieved in ServiceNow. You can do but not directly within the email body (emails are static and cannot dynamically show/hide content after they are sent). However, you can guide users to a dynamic form/survey in ServiceNow to achieve the desired conditional logic.

If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.

 

Thanks & Regards
Viraj Hudlikar.

PritamG
Mega Guru

 

open the required notification or create a new one.

add a dynamic condition In the condition section, check if the field "Is this in scope of MF2 initiative?" is Yes.

use mail script in the email body add a mail script or inline if condition to display "MF2" only when the condition is met:

<% if (current.u_mf2_initiative == 'Yes') { %>
    MF2
<% } %>

If using HTML, insert

${current.u_mf2_initiative == 'Yes' ? 'MF2' : ''}

 

Priyankagupta
Giga Guru

Hello @JVINAY, if you would like to make email body visible based on the value of another field, you can use email script to achieve this.

refer - Scripting for email notifications

 

Please mark reply as Helpful/Correct, if applicable. Thanks!

@Priyankagupta ,

Below code i am developing, which table i need to glide ( var grSD = new GlideRecord('     ');)

Please help me to which should I glide/select .

and if it's possible correct my below code.

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

    // Add your code here

    var mf2initiative = [];
    var grSD = new GlideRecord('     ');
    grSD.addEncodedQuery('sys_idIN' + current.mf2_initiative.toString());
    grSD.query();
    while (grSD.next()) {
        mf2initiative.push(grSD.getValue('name'));
    }
    if (mf2initiative.length === 0) {
        template.print('None');
    } else {
        template.print(mf2initiative.join(','));
    }



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