- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2023 04:55 AM
We have create one notification which will be triggered if RITM is not approved after 5 days. hence in this notification we are triggering some dynamic values also and for that created one email script where the code is already we are getting the dynamic values from the raised RITM and populating in the notification,
All the dnamic values are basicalled we getting from the different variables of the RITM and this code is already wqritten.
Now i just need to make some changes in email script so that it will populate variable "apprpoval's name" as the "Dear approver : Username(apprpoval's name) in the notification. please suggest how can i populate this approver name.
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
// Add your code here
template.print("Summary of Requested items:<br />");
var item = new GlideRecord("sc_req_item");
item.addQuery("sys_id", current.sys_id);
item.query();
while (item.next()) {
template.print(item.number + ": " + item.cat_item.getDisplayValue() +" Request<br />");
template.print(" Details:<br />");
var keys = [];
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(item.sys_id);
set.load();
var vs = set.getFlatQuestions();
for (var i = 0; i < vs.size(); i++) {
if (vs.get(i).getLabel() != '') {
template.space(4);
template.print(' ' + vs.get(i).getLabel() + " : " + vs.get(i).getDisplayValue() + "<br />");
}
}
}
})(current, template, email, email_action, event);
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2023 05:02 AM - edited ‎04-13-2023 09:23 AM
Please write an email script & call it in your notification.
Name = "example_name"
(function runMailScript(current, template, email, email_action, event) {
var gr = new GlideRecord('sc_cat_item');
gr.addQuery('sys_id', current.sys_id);
gr.query();
if (gr.next())
{
if (gr.cat_item == 'sys_id_of_catalog1') {
template.print(current.variables.server_1);
template.print(current.variables.server_2);
template.print(current.variables.server_3);
email.setSubject("For catalog item 1");
}
else if (gr.cat_item == 'sys_id_of_catalog2') {
template.print(current.variables.database1);
template.print(current.variables.database2);
template.print(current.variables.database3);
email.setSubject("For catalog item 2");
}
}
})(current, template, email, email_action, event);
Then call this email script in the notification
${mail_script:example_name}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2023 05:45 AM - edited ‎04-13-2023 05:45 AM
Once you have an email script created, you can call it from any notification by adding an entry in the notification "Message HTML" field like this example:
${mail_script:bca.healthcheck.email}
In this example, the email script is called "bca.healthecheck.email" so you would replace that bit with the name of your email script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2023 06:13 AM
Kindly check my above comments i have called it fro tghe notification but not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2023 06:18 AM
Try removing the "Dear Approver:" part in front of the script call; maybe just put them on separate lines so there is nothing else on the same line that you are calling the script from.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2023 06:13 AM
Hi,
Try something like that
template.print("Dear Approver: " + current.variables.approvers_e_mail_address.getDisplayValue());
// Check the name of the approver variable
Regards,