- 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 06:00 AM - edited ‎04-13-2023 09:24 AM
Did you 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 06:08 AM
Below is the sccrrenshot that how i am calling my email scrit
my email script name is : Adding_Email_approver_for_Stockade
Its just not working

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2023 06:27 AM - edited ‎04-13-2023 06:28 AM
It should work. Please check the backend name of the email variable you are calling in your script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2023 07:21 AM
ITs working now, basically instaed of "Sc_cat_item" we need to glide the table "SC_Req_item".
Thanks for the help

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2023 07:23 AM
Glad to know that 🤗