Incident form fields visible in Notification

Servicenow de11
Tera Contributor

Hello,

 

I have a requirement that is in the incident form we have field called  BRIDGE INFORMATION. The field type is true/false. If the  user selects the Bridge information check box , in the notification it will visible like BRIDGE REQUIRED.

If the user did not check the bridge information field , in the notification it will visible like BRIDGE NOT REQUIRED.

Attached screenshots

Can anyone suggest me notification email script to achieve this.

 

Thanks in advance

2 ACCEPTED SOLUTIONS

S Goutham
Tera Guru

hey @Servicenow de11 

You need to write the mail script for this functionality 

something like below

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {
if (current.< your_checkbox_name> )
    template.print('Required');
else
    template.print('Not Required');
})(current, template, email, email_action, event);

and call the mail script in place of the field ${field_name} to ${mail_script:<your_mail_script_name}

 

I hope this solves your issue
Mark this as Helpful / Accept the Solution if this clears your issue

View solution in original post

Vishal Birajdar
Giga Sage

Hello @Servicenow de11 

 

Can you try this...!!

 

Step 1 : Create email script 

 

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

    var getBridgeValue = current.getValue('u_bridge_information');

    if (getBridgeValue == true || getBridgeValue == 'true') {

        template.print("Bridge Required");

    } else {

        //if you want anything to print

    }

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

 

 

VishalBirajdar7_0-1694526722364.png

 

 

Step 2: Call mail script in your notifcation

 

${mail_script:BridgeRequired}

 

VishalBirajdar7_1-1694526871547.png

 

Output : 

VishalBirajdar7_2-1694526961344.png

 

 

 

 

 

 

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

View solution in original post

3 REPLIES 3

S Goutham
Tera Guru

hey @Servicenow de11 

You need to write the mail script for this functionality 

something like below

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {
if (current.< your_checkbox_name> )
    template.print('Required');
else
    template.print('Not Required');
})(current, template, email, email_action, event);

and call the mail script in place of the field ${field_name} to ${mail_script:<your_mail_script_name}

 

I hope this solves your issue
Mark this as Helpful / Accept the Solution if this clears your issue

Its working, thanks for the script

Vishal Birajdar
Giga Sage

Hello @Servicenow de11 

 

Can you try this...!!

 

Step 1 : Create email script 

 

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

    var getBridgeValue = current.getValue('u_bridge_information');

    if (getBridgeValue == true || getBridgeValue == 'true') {

        template.print("Bridge Required");

    } else {

        //if you want anything to print

    }

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

 

 

VishalBirajdar7_0-1694526722364.png

 

 

Step 2: Call mail script in your notifcation

 

${mail_script:BridgeRequired}

 

VishalBirajdar7_1-1694526871547.png

 

Output : 

VishalBirajdar7_2-1694526961344.png

 

 

 

 

 

 

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates