need to call email script in notification???

Srvs
Kilo Guru

Hi

I have email script as follows

<mail_script>

var item = new GlideRecord("sc_req_item");

item.addQuery("request", current.sys_id);

item.query();

while(item.next()) {

var catalogItem = item.number + ': ' + item.cat_item.getDisplayValue();

var misc = item.variable_pool.alt_poc;

template.print(catalogItem + "<br/> Field: " + misc);

}

</mail_script>

I need to call this script in notifications, please help me out how can i do this?? with example or screen shot.

Any help is greatly appreciated (with examples)

--venky

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Venkatesh



Create mail scripts in System Policy > Email > Notification Email Script->


(function runMailScript(current, template, email, email_action, event) {


  var item = new GlideRecord("sc_req_item");


  item.addQuery("request", current.sys_id);


  item.query();


  while(item.next()) {


  var catalogItem = item.number + ': ' + item.cat_item.getDisplayValue();


  var misc = item.variable_pool.alt_poc;


  template.print(catalogItem + "<br/> Field: " + misc);


  }


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





Now you can call the above mail script in email notification(Message HTML) as ${mail_script:script name}


Here replace script name with the exact name of the notification email script you have created in step 1.


View solution in original post

8 REPLIES 8

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Venkatesh



Create mail scripts in System Policy > Email > Notification Email Script->


(function runMailScript(current, template, email, email_action, event) {


  var item = new GlideRecord("sc_req_item");


  item.addQuery("request", current.sys_id);


  item.query();


  while(item.next()) {


  var catalogItem = item.number + ': ' + item.cat_item.getDisplayValue();


  var misc = item.variable_pool.alt_poc;


  template.print(catalogItem + "<br/> Field: " + misc);


  }


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





Now you can call the above mail script in email notification(Message HTML) as ${mail_script:script name}


Here replace script name with the exact name of the notification email script you have created in step 1.


hi pradeep,


i have a field calld mobile_number in catalog item.


but iam not getting data entered in that field, i am getting some "MSG00008" as a email.


Hi Pradeep,

How can I add two different email scripts body into one email script?